Skip to content

Instantly share code, notes, and snippets.

@aqzlpm11
Last active July 16, 2017 08:01
Show Gist options
  • Save aqzlpm11/a0ac7538d3f1c0b72954f95677ce7c41 to your computer and use it in GitHub Desktop.
Save aqzlpm11/a0ac7538d3f1c0b72954f95677ce7c41 to your computer and use it in GitHub Desktop.
python: performance analysing example.
#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