diff --git a/demos/benchmark/template_benchmark.py b/demos/benchmark/template_benchmark.py new file mode 100755 index 00000000..07833af7 --- /dev/null +++ b/demos/benchmark/template_benchmark.py @@ -0,0 +1,62 @@ +#!/usr/bin/env python +# +# A simple benchmark of tornado template rendering, based on +# https://github.com/mitsuhiko/jinja2/blob/master/examples/bench.py + +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') + +context = { + 'page_title': 'mitsuhiko\'s benchmark', + 'table': [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) for x in range(1000)] +} + +tmpl = Template("""\ + + +
+{{ cell }} | + {% end %} +