From: Armin Ronacher Date: Thu, 1 Jul 2010 10:15:35 +0000 (+0200) Subject: Updated rwbench X-Git-Tag: 2.5.1~11 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=5a8d49689a0cb5b517d784303cad4cc63cb6d927;p=jinja2.git Updated rwbench --HG-- branch : trunk --- diff --git a/examples/rwbench/rwbench.py b/examples/rwbench/rwbench.py index 9cb3195..813dd56 100644 --- a/examples/rwbench/rwbench.py +++ b/examples/rwbench/rwbench.py @@ -12,6 +12,11 @@ """ 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' % 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()