changeset 815:7d94b77281f2

Switch profiling in the benchmarks to cProfile.
author cmlenz
date Mon, 09 Mar 2009 16:14:43 +0000
parents ecd7ad13bdaf
children 87e3fc814a33
files examples/bench/basic.py examples/bench/bigtable.py
diffstat 2 files changed, 17 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/examples/bench/basic.py
+++ b/examples/bench/basic.py
@@ -190,12 +190,15 @@
     verbose = '-v' in sys.argv
 
     if '-p' in sys.argv:
-        import hotshot, hotshot.stats
-        prof = hotshot.Profile("template.prof")
-        benchtime = prof.runcall(run, engines, number=100, verbose=verbose)
-        stats = hotshot.stats.load("template.prof")
+        import cProfile, pstats
+        prof = cProfile.Profile()
+        prof.run('run(%r, number=200, verbose=%r)' % (engines, verbose))
+        stats = pstats.Stats(prof)
         stats.strip_dirs()
-        stats.sort_stats('time', 'calls')
-        stats.print_stats(.05)
+        stats.sort_stats('calls')
+        stats.print_stats(25)
+        if verbose:
+            stats.print_callees()
+            stats.print_callers()
     else:
         run(engines, verbose=verbose)
--- a/examples/bench/bigtable.py
+++ b/examples/bench/bigtable.py
@@ -219,12 +219,15 @@
     which = [arg for arg in sys.argv[1:] if arg[0] != '-']
 
     if '-p' in sys.argv:
-        import hotshot, hotshot.stats
-        prof = hotshot.Profile("template.prof")
-        benchtime = prof.runcall(run, which, number=1)
-        stats = hotshot.stats.load("template.prof")
+        import cProfile, pstats
+        prof = cProfile.Profile()
+        prof.run('run(%r, number=1)' % which)
+        stats = pstats.Stats(prof)
         stats.strip_dirs()
         stats.sort_stats('time', 'calls')
-        stats.print_stats()
+        stats.print_stats(25)
+        if '-v' in sys.argv:
+            stats.print_callees()
+            stats.print_callers()
     else:
         run(which)
Copyright (C) 2012-2017 Edgewall Software