Added tornado templates to benchmark.
authorArmin Ronacher <armin.ronacher@active-4.com>
Thu, 10 Sep 2009 20:58:52 +0000 (13:58 -0700)
committerArmin Ronacher <armin.ronacher@active-4.com>
Thu, 10 Sep 2009 20:58:52 +0000 (13:58 -0700)
--HG--
branch : trunk

examples/bench.py

index 49b1c752aa55a68d9a9ee100dfc203cc8b673705..0d5a68fef62166b14feb892020abba9dc626be6d 100644 (file)
@@ -54,6 +54,48 @@ jinja_template = JinjaEnvironment(
 def test_jinja():
     jinja_template.render(context)
 
+try:
+    from tornado.template import Template
+except ImportError:
+    test_tornado = None
+else:
+    tornado_template = Template("""\
+<!doctype html>
+<html>
+  <head>
+    <title>{{ page_title }}</title>
+  </head>
+  <body>
+    <div class="header">
+      <h1>{{ page_title }}</h1>
+    </div>
+    <ul class="navigation">
+    {% for href, caption in [ \
+        ('index.html', 'Index'), \
+        ('downloads.html', 'Downloads'), \
+        ('products.html', 'Products') \
+      ] %}
+      <li><a href="{{ href }}">{{ caption }}</a></li>
+    {% end %}
+    </ul>
+    <div class="table">
+      <table>
+      {% for row in table %}
+        <tr>
+        {% for cell in row %}
+          <td>{{ cell }}</td>
+        {% end %}
+        </tr>
+      {% end %}
+      </table>
+    </div>
+  </body>
+</html>\
+""")
+
+    def test_tornado():
+        tornado_template.generate(**context)
+
 try:
     from django.conf import settings
     settings.configure()
@@ -300,7 +342,7 @@ sys.stdout.write('\r' + '\n'.join((
 )) + '\n')
 
 
-for test in 'jinja', 'mako', 'tenjin', 'spitfire', 'django', 'genshi', 'cheetah':
+for test in 'jinja', 'mako', 'tornado', 'tenjin', 'spitfire', 'django', 'genshi', 'cheetah':
     if locals()['test_' + test] is None:
         sys.stdout.write('    %-20s*not installed*\n' % test)
         continue