Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cProfile
- print("Generator Runtime Stats:")
- cProfile.run('sum((i for i in range(100000)))')
- print("List Runtime Stats:")
- cProfile.run('sum([i for i in range(100000)])')
- Generator Runtime Stats:
- 100005 function calls in 0.123 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 100001 0.015 0.000 0.015 0.000 <string>:1(<genexpr>)
- 1 0.000 0.000 0.123 0.123 <string>:1(<module>)
- 1 0.000 0.000 0.123 0.123 {built-in method builtins.exec}
- 1 0.108 0.108 0.122 0.122 {built-in method builtins.sum}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
- List Runtime Stats:
- 5 function calls in 0.012 seconds
- Ordered by: standard name
- ncalls tottime percall cumtime percall filename:lineno(function)
- 1 0.010 0.010 0.010 0.010 <string>:1(<listcomp>)
- 1 0.001 0.001 0.012 0.012 <string>:1(<module>)
- 1 0.000 0.000 0.012 0.012 {built-in method builtins.exec}
- 1 0.001 0.001 0.001 0.001 {built-in method builtins.sum}
- 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement