Created
June 1, 2024 02:56
-
-
Save js51/408bfaf53c3db877ebca182a78f90557 to your computer and use it in GitHub Desktop.
Code for profiling functions in python
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
| from cProfile import Profile | |
| from pstats import SortKey, Stats | |
| with Profile() as profile: | |
| # Code goes here | |
| my_function() | |
| # # # | |
| print( | |
| Stats(profile) | |
| .strip_dirs() | |
| .sort_stats('cumtime') | |
| .print_stats() | |
| .print_callees() | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment