Last active
July 16, 2017 08:01
-
-
Save aqzlpm11/a0ac7538d3f1c0b72954f95677ce7c41 to your computer and use it in GitHub Desktop.
python: performance analysing example.
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
#encoding=utf-8 | |
import cProfile | |
import pstats | |
def fun(): | |
return sum([i for i in range(10000000)]) | |
if __name__ == "__main__": | |
cProfile.run('fun()', "result") | |
p = pstats.Stats("result") | |
# p.strip_dirs().sort_stats("tottime").print_stats(10) | |
p.strip_dirs().sort_stats("cumtime").print_stats(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment