Skip to content

Instantly share code, notes, and snippets.

@dragonly
Created December 30, 2019 02:39
Show Gist options
  • Save dragonly/d3b199254df7d0f2e3946295c61b69bf to your computer and use it in GitHub Desktop.
Save dragonly/d3b199254df7d0f2e3946295c61b69bf to your computer and use it in GitHub Desktop.
python profile
profile = cProfile.Profile()
profile.enable()
'''
code to profile
'''
profile.disable()
s = io.StringIO()
ps = pstats.Stats(profile, stream=s).sort_stats('tottime').reverse_order()
ps.print_stats()
print(s.getvalue())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment