Created
June 24, 2010 22:53
-
-
Save codekoala/452105 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ python test_enumerate.py | |
3 function calls in 8.030 CPU seconds | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.000 0.000 8.030 8.030 <string>:1(<module>) | |
1 8.030 8.030 8.030 8.030 test_enumerate.py:5(test_enumerate) | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} | |
3 function calls in 9.748 CPU seconds | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.000 0.000 9.748 9.748 <string>:1(<module>) | |
1 9.748 9.748 9.748 9.748 test_enumerate.py:9(test_increment) | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cProfile | |
ITER = 100000000 | |
def test_enumerate(): | |
for idx, i in enumerate(xrange(ITER)): | |
pass | |
def test_increment(): | |
idx = 0 | |
for i in xrange(ITER): | |
idx += 1 | |
if __name__ == '__main__': | |
cProfile.run('test_enumerate()') | |
cProfile.run('test_increment()') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment