Created
April 16, 2019 03:41
-
-
Save SkamDart/dcd3bb7ca213962f1eb6e7394049ab51 to your computer and use it in GitHub Desktop.
Beginner Python CProfile Usage
This file contains 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
"""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