Updated rwbench
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 1 Jul 2010 10:15:35 +0000 (12:15 +0200)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 1 Jul 2010 10:15:35 +0000 (12:15 +0200)
--HG--
branch : trunk

examples/rwbench/rwbench.py

index 9cb3195a3472b8d35710c750142b2263acf6c0b5..813dd56cf714311ff5a89fff68f8fe7a30c9310c 100644 (file)
 """
 import sys
 from os.path import join, dirname, abspath
+try:
+    from cProfile import Profile
+except ImportError:
+    from profile import Profile
+from pstats import Stats
 ROOT = abspath(dirname(__file__))
 
 from random import choice, randrange
@@ -97,3 +102,11 @@ if __name__ == '__main__':
         sys.stdout.write(' >> %-20s<running>' % test)
         sys.stdout.flush()
         sys.stdout.write('\r    %-20s%.4f seconds\n' % (test, t.timeit(number=200) / 200))
+
+    if '-p' in sys.argv:
+        print 'Jinja profile'
+        p = Profile()
+        p.runcall(test_jinja)
+        stats = Stats(p)
+        stats.sort_stats('time', 'calls')
+        stats.print_stats()