]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Add option to print out generated template code in benchmark
authorBen Darnell <ben@bendarnell.com>
Thu, 28 Jul 2011 05:09:49 +0000 (22:09 -0700)
committerBen Darnell <ben@bendarnell.com>
Thu, 28 Jul 2011 05:09:49 +0000 (22:09 -0700)
demos/benchmark/template_benchmark.py

index 07833af74ef20a8be623f0cc5e37c6d55f7121fa..a38c689c93c3b2c8934818dca94851fd33b7a2c3 100755 (executable)
@@ -3,12 +3,14 @@
 # A simple benchmark of tornado template rendering, based on
 # https://github.com/mitsuhiko/jinja2/blob/master/examples/bench.py
 
+import sys
 from timeit import Timer
 
 from tornado.options import options, define, parse_command_line
 from tornado.template import Template
 
 define('num', default=100, help='number of iterations')
+define('dump', default=False, help='print template generated code and exit')
 
 context = {
     'page_title': 'mitsuhiko\'s benchmark',
@@ -54,6 +56,9 @@ def render():
 
 def main():
     parse_command_line()
+    if options.dump:
+        print tmpl.code
+        sys.exit(0)
     t = Timer(render)
     results = t.timeit(options.num) / options.num
     print '%0.3f ms per iteration' % (results*1000)