Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. import cProfile
  2.  
  3. print("Generator Runtime Stats:")
  4. cProfile.run('sum((i for i in range(100000)))')
  5.  
  6. print("List Runtime Stats:")
  7. cProfile.run('sum([i for i in range(100000)])')
  8.  
  9. Generator Runtime Stats:
  10. 100005 function calls in 0.123 seconds
  11.  
  12. Ordered by: standard name
  13.  
  14. ncalls tottime percall cumtime percall filename:lineno(function)
  15. 100001 0.015 0.000 0.015 0.000 <string>:1(<genexpr>)
  16. 1 0.000 0.000 0.123 0.123 <string>:1(<module>)
  17. 1 0.000 0.000 0.123 0.123 {built-in method builtins.exec}
  18. 1 0.108 0.108 0.122 0.122 {built-in method builtins.sum}
  19. 1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
  20.  
  21.  
  22. List Runtime Stats:
  23. 5 function calls in 0.012 seconds
  24.  
  25. Ordered by: standard name
  26.  
  27. ncalls tottime percall cumtime percall filename:lineno(function)
  28. 1 0.010 0.010 0.010 0.010 <string>:1(<listcomp>)
  29. 1 0.001 0.001 0.012 0.012 <string>:1(<module>)
  30. 1 0.000 0.000 0.012 0.012 {built-in method builtins.exec}
  31. 1 0.001 0.001 0.001 0.001 {built-in method builtins.sum}
  32. 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