Skip to content

Instantly share code, notes, and snippets.

@SkamDart SkamDart/prof.py
Created Apr 16, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.