Skip to content

Instantly share code, notes, and snippets.

@ogroleg
ogroleg / module_profiler.py
Created August 4, 2016 08:01 — forked from jebeck/README.md
profile a Python module with hotshot
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')