Last active
July 14, 2018 14:58
-
-
Save rafaelhenrique/076880576a31a8121407b3274e8847bc to your computer and use it in GitHub Desktop.
Python profile some code
This file contains hidden or 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
| 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() |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
References: