Skip to content

Instantly share code, notes, and snippets.

@SkamDart
Created April 16, 2019 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SkamDart/dcd3bb7ca213962f1eb6e7394049ab51 to your computer and use it in GitHub Desktop.
Save SkamDart/dcd3bb7ca213962f1eb6e7394049ab51 to your computer and use it in GitHub Desktop.
Beginner Python CProfile Usage
"""Example usage for cprofile
pip install gprof2dot
"""
import cProfile
import pstats
import StringIO
pr = cProfile.Profile()
# start profiling
pr.enable()
# end profiling
pr.disable()
s = StringIO.StringIO()
sortby = 'cumulative'
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment