Skip to content

Instantly share code, notes, and snippets.

@beltiras
Created October 29, 2015 15:17
Show Gist options
  • Save beltiras/a9f19af5d9469549020e to your computer and use it in GitHub Desktop.
Save beltiras/a9f19af5d9469549020e to your computer and use it in GitHub Desktop.
def test_it(iter):
s = 0
for i in xrange(0,iter):
p = sum([randint(0,10000000) for i in xrange(0,iter)])
s += p
print s
### methodology:
"""
beltiras@BigWizard:~$ source pypyenv/bin/activate
(pypyenv)beltiras@BigWizard:~$ ipython
Python 2.7.10 (850edf14b2c7, Oct 26 2015, 06:41:12)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from measure import test_it
In [2]: %timeit test_it(5000)
125004725113345
124997956766677
124970125407310
125009783419791
1 loops, best of 3: 2.53 s per loop
In [3]:
Do you really want to exit ([y]/n)?
(pypyenv)beltiras@BigWizard:~$ deactivate
beltiras@BigWizard:~$ source env/bin/activate
(env)beltiras@BigWizard:~$ ipython
Python 2.7.6 (default, Jun 22 2015, 17:58:13)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from measure import test_it
In [2]: %timeit test_it(5000)
125005071228460
125004021387981
124988432693390
125003903191632
1 loops, best of 3: 1min 34s per loop
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment