Last active
August 29, 2015 14:24
-
-
Save travcunn/1acdacfb32b8a8f7f380 to your computer and use it in GitHub Desktop.
This file contains 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
>>> x = [] | |
>>> y = [] | |
>>> | |
>>> def test_loop(): | |
... for _ in range(5000000): | |
... x.append(_) | |
... | |
>>> def test_map(): | |
... map(y.append, range(5000000)) | |
... | |
>>> | |
>>> import cProfile | |
>>> | |
>>> cProfile.run('test_loop()') | |
5000004 function calls in 0.842 seconds | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.595 0.595 0.842 0.842 <stdin>:1(test_loop) | |
1 0.000 0.000 0.842 0.842 <string>:1(<module>) | |
5000000 0.189 0.000 0.189 0.000 {method 'append' of 'list' objects} | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} | |
1 0.058 0.058 0.058 0.058 {range} | |
>>> cProfile.run('test_map()') | |
5 function calls in 0.282 seconds>>> | |
Ordered by: standard name | |
ncalls tottime percall cumtime percall filename:lineno(function) | |
1 0.032 0.032 0.282 0.282 <stdin>:1(test_map) | |
1 0.000 0.000 0.282 0.282 <string>:1(<module>) | |
1 0.193 0.193 0.193 0.193 {map} | |
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects} | |
1 0.058 0.058 0.058 0.058 {range} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment