comparison examples/bench/basic.py @ 815:7d94b77281f2

Switch profiling in the benchmarks to cProfile.
author cmlenz
date Mon, 09 Mar 2009 16:14:43 +0000
parents 72e1a2ed04a0
children
comparison
equal deleted inserted replaced
814:ecd7ad13bdaf 815:7d94b77281f2
188 engines = __all__ 188 engines = __all__
189 189
190 verbose = '-v' in sys.argv 190 verbose = '-v' in sys.argv
191 191
192 if '-p' in sys.argv: 192 if '-p' in sys.argv:
193 import hotshot, hotshot.stats 193 import cProfile, pstats
194 prof = hotshot.Profile("template.prof") 194 prof = cProfile.Profile()
195 benchtime = prof.runcall(run, engines, number=100, verbose=verbose) 195 prof.run('run(%r, number=200, verbose=%r)' % (engines, verbose))
196 stats = hotshot.stats.load("template.prof") 196 stats = pstats.Stats(prof)
197 stats.strip_dirs() 197 stats.strip_dirs()
198 stats.sort_stats('time', 'calls') 198 stats.sort_stats('calls')
199 stats.print_stats(.05) 199 stats.print_stats(25)
200 if verbose:
201 stats.print_callees()
202 stats.print_callers()
200 else: 203 else:
201 run(engines, verbose=verbose) 204 run(engines, verbose=verbose)
Copyright (C) 2012-2017 Edgewall Software