Skip to content
Myr

Added benchmark for chameleon/chameleon-genshi.

Before adoption: this commit came in with the history the project adopted, so no landing records it.

--HG-- branch : trunk

authored by Rodrigo Moraes · committed by Rodrigo Moraes · parent dd0039c · Browse files · 1 file+76 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+76 added−1 removed

  • other:+76 added−1 removed

1 file+76 added−1 removed

modified:examples/bench.py+76 added-1 removed
328 unmodified lines
329330 def test_spitfire():331 spitfire_template(search_list=[spitfire_context]).main()332333334try:335 from chameleon.zpt.template import PageTemplate336except ImportError:337 test_chameleon = None338else:339 chameleon_template = PageTemplate("""\340<html xmlns:tal="http://xml.zope.org/namespaces/tal">341 <head>342 <title tal:content="page_title">Page Title</title>343 </head>344 <body>345 <div class="header">346 <h1 tal:content="page_title">Page Title</h1>347 </div>348 <ul class="navigation">349 <li tal:repeat="item sections"><a tal:attributes="href item[0]" tal:content="item[1]">caption</a></li>350 </ul>351 <div class="table">352 <table>353 <tr tal:repeat="row table">354 <td tal:repeat="cell row" tal:content="row[cell]">cell</td>355 </tr>356 </table>357 </div>358 </body>359</html>\360""")361 chameleon_context = dict(context)362 chameleon_context['sections'] = [363 ('index.html', 'Index'),364 ('downloads.html', 'Downloads'),365 ('products.html', 'Products')366 ]367 def test_chameleon():368 chameleon_template.render(**chameleon_context)369370try:371 from chameleon.zpt.template import PageTemplate372 from chameleon.genshi import language373except ImportError:374 test_chameleon_genshi = None375else:376 chameleon_genshi_template = PageTemplate("""\377<html xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">378 <head>379 <title>${page_title}</title>380 </head>381 <body>382 <div class="header">383 <h1>${page_title}</h1>384 </div>385 <ul class="navigation">386 <li py:for="info in sections"><a href="${info[0]}">${info[1]}</a></li>387 </ul>388 <div class="table">389 <table>390 <tr py:for="row in table">391 <td py:for="cell in row">${row[cell]}</td>392 </tr>393 </table>394 </div>395 </body>396</html>\397""", parser=language.Parser())398 chameleon_genshi_context = dict(context)399 chameleon_genshi_context['sections'] = [400 ('index.html', 'Index'),401 ('downloads.html', 'Downloads'),402 ('products.html', 'Products')403 ]404 def test_chameleon_genshi():405 chameleon_genshi_template.render(**chameleon_genshi_context)406407408sys.stdout.write('\r' + '\n'.join((409 '=' * 80,410 'Template Engine BigTable Benchmark'.center(80),411 '=' * 80,
1 unmodified line
413 '-' * 80414)) + '\n')415416342for test in 'jinja', 'mako', 'tornado', 'tenjin', 'spitfire', 'django', 'genshi', 'cheetah':417for test in 'jinja', 'mako', 'tornado', 'tenjin', 'spitfire', 'django', 'genshi', 'cheetah', 'chameleon', 'chameleon_genshi':418 if locals()['test_' + test] is None:419 sys.stdout.write(' %-20s*not installed*\n' % test)420 continue421 t = Timer(setup='from __main__ import test_%s as bench' % test,
12 unmodified lines