Skip to content

Commit

Permalink
Added tornado templates to benchmark.
Browse files Browse the repository at this point in the history
--HG--
branch : trunk
  • Loading branch information
mitsuhiko committed Sep 10, 2009
1 parent bd35772 commit b4da9be
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion examples/bench.py
Expand Up @@ -54,6 +54,48 @@
def test_jinja(): def test_jinja():
jinja_template.render(context) 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: try:
from django.conf import settings from django.conf import settings
settings.configure() settings.configure()
Expand Down Expand Up @@ -300,7 +342,7 @@ def test_spitfire():
)) + '\n') )) + '\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: if locals()['test_' + test] is None:
sys.stdout.write(' %-20s*not installed*\n' % test) sys.stdout.write(' %-20s*not installed*\n' % test)
continue continue
Expand Down

0 comments on commit b4da9be

Please sign in to comment.