gaphas/examples/demo_profile.py
Dan Yeaw 374c30da28
Fix F401 for unused imports
Signed-off-by: Dan Yeaw <dan@yeaw.me>
2020-08-20 21:56:40 -04:00

24 lines
622 B
Python

#!/usr/bin/env python
from examples.demo import main
if __name__ == "__main__":
try:
import cProfile
import pstats
cProfile.run("main()", "demo-gaphas.prof")
p = pstats.Stats("demo-gaphas.prof")
p.strip_dirs().sort_stats("time").print_stats(40)
except ImportError:
import hotshot
import hotshot.stats
prof = hotshot.Profile("demo-gaphas.prof")
prof.runcall(main)
prof.close()
stats = hotshot.stats.load("demo-gaphas.prof")
stats.strip_dirs()
stats.sort_stats("time", "calls")
stats.print_stats(20)