Skip to content

Instantly share code, notes, and snippets.

@rafaelhenrique
Last active July 14, 2018 14:58
Show Gist options
  • Select an option

  • Save rafaelhenrique/076880576a31a8121407b3274e8847bc to your computer and use it in GitHub Desktop.

Select an option

Save rafaelhenrique/076880576a31a8121407b3274e8847bc to your computer and use it in GitHub Desktop.
Python profile some code
import cProfile
import pstats
import io
import pdb
pr = cProfile.Profile()
pr.enable()
[code here]
pr.disable()
s = io.StringIO()
ps = pstats.Stats(pr, stream=s).sort_stats('cumulative')
ps.print_stats(10)
print(s.getvalue())
pdb.set_trace()
@rafaelhenrique

rafaelhenrique commented Jul 14, 2018

Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment