-
-
Save ogroleg/3d56643d4924fd436f0f798c768bcd2b to your computer and use it in GitHub Desktop.
profile a Python module with hotshot
This file contains 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 hotshot, hotshot.stats | |
import sys | |
def main(): | |
module = __import__(sys.argv[1].replace('.py', '')) | |
prof = hotshot.Profile('example.prof') | |
prof.runcall(module.main) | |
prof.close() | |
stats = hotshot.stats.load('example.prof') | |
stats.strip_dirs() | |
stats.sort_stats('time', 'calls') | |
stats.print_stats() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment