# HG changeset patch # User drewp@bigasterisk.com # Date 1402801788 0 # Node ID 5e905ff44e843b3d9eb3a678af77ded01e8d816a # Parent f0d752c0a7722ddf67560cdaedc7b75200705d71 CC now suports statprof profiling, and every other profile() call is now broken Ignore-this: bc7c31af6598e7c132d2f847afe8de68 diff -r f0d752c0a772 -r 5e905ff44e84 bin/curvecalc --- a/bin/curvecalc Sun Jun 15 02:53:33 2014 +0000 +++ b/bin/curvecalc Sun Jun 15 03:09:48 2014 +0000 @@ -490,7 +490,7 @@ help="live reload of themes and code") parser.add_option("--startup-only", action='store_true', help="quit after loading everything (for timing tests)") - parser.add_option("--profile", action='store_true', help='profile') + parser.add_option("--profile", help='"hotshot" or "stat"') clientsession.add_option(parser) opts, args = parser.parse_args() diff -r f0d752c0a772 -r 5e905ff44e84 light9/prof.py --- a/light9/prof.py Sun Jun 15 02:53:33 2014 +0000 +++ b/light9/prof.py Sun Jun 15 03:09:48 2014 +0000 @@ -1,16 +1,25 @@ import sys, traceback, time, logging log = logging.getLogger() -def run(main, profile=False): +def run(main, profile=None): if not profile: main() return - - import hotshot, hotshot.stats - p = hotshot.Profile("/tmp/pro") - p.runcall(main) - p.close() - hotshot.stats.load("/tmp/pro").sort_stats('cumulative').print_stats() + + if profile == 'hotshot': + import hotshot, hotshot.stats + p = hotshot.Profile("/tmp/pro") + p.runcall(main) + p.close() + hotshot.stats.load("/tmp/pro").sort_stats('cumulative').print_stats() + elif profile == 'stat': + import statprof + statprof.start() + try: + main() + finally: + statprof.stop() + statprof.display() def watchPoint(filename, lineno, event="call"): """whenever we hit this line, print a stack trace. event='call'