[Checkins] SVN: z3c.pt/trunk/ Added a new benchmark test called bigtable that produces results which are directly comparable to th

Hanno Schlichting plone at hannosch.info
Thu Jul 17 16:51:54 EDT 2008


Log message for revision 88465:
  Added a new benchmark test called bigtable that produces results which are directly comparable to th
  ose produced by the bigtable.py benchmark in the spitfire project.
  

Changed:
  U   z3c.pt/trunk/CHANGES.txt
  A   z3c.pt/trunk/benchmark/benchmark/bigtable.py
  U   z3c.pt/trunk/buildout.cfg

-=-
Modified: z3c.pt/trunk/CHANGES.txt
===================================================================
--- z3c.pt/trunk/CHANGES.txt	2008-07-17 19:44:22 UTC (rev 88464)
+++ z3c.pt/trunk/CHANGES.txt	2008-07-17 20:51:51 UTC (rev 88465)
@@ -4,6 +4,10 @@
 Version 0.8.x
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+- Added a new benchmark test called bigtable that produces results which are
+  directly comparable to those produced by the bigtable.py benchmark in the
+  spitfire project.
+
 - Introduce a new config option called `Z3C_PT_DISABLE_I18N`. If this
   environment variable is set to `true`, the template engine will not call
   into the zope.i18n machinery anymore, but fall back to simple interpolation

Added: z3c.pt/trunk/benchmark/benchmark/bigtable.py
===================================================================
--- z3c.pt/trunk/benchmark/benchmark/bigtable.py	                        (rev 0)
+++ z3c.pt/trunk/benchmark/benchmark/bigtable.py	2008-07-17 20:51:51 UTC (rev 88465)
@@ -0,0 +1,79 @@
+# This test is adopted from the spifire project, which has an extensive
+# test suite of different templating languages.
+
+# You can run it via: bin/py benchmark/benchmark/bigtable.py
+
+import sys
+import timeit
+
+import zope.component.testing
+import zope.configuration.xmlconfig
+import zope.pagetemplate.pagetemplate
+
+import z3c.pt
+
+bigtable_z3c = z3c.pt.PageTemplate("""
+<table xmlns="http://www.w3.org/1999/xhtml"
+xmlns:tal="http://xml.zope.org/namespaces/tal">
+<tr tal:repeat="row table">
+<td tal:repeat="column row.values()" tal:content="column">
+</td></tr></table>
+""")
+
+bigtable_zope = zope.pagetemplate.pagetemplate.PageTemplate()
+bigtable_zope.pt_edit("""\
+<table xmlns="http://www.w3.org/1999/xhtml"
+xmlns:tal="http://xml.zope.org/namespaces/tal">
+<tr tal:repeat="row python: options['table']">
+<td tal:repeat="c python: row.values()" tal:content="c">
+</td></tr></table>""", 'text/xhtml')
+
+
+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)]
+
+def setup():
+    zope.component.testing.setUp()
+    zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
+
+def test_z3c():
+    """z3c.pt template"""
+    data = bigtable_z3c(table=table)
+
+def test_zope():
+    """zope.pagetemplate template"""
+    data = bigtable_zope(table=table)
+
+def run(which=None, number=10):
+    tests = ['test_z3c', 'test_zope']
+
+    if which:
+        tests = ['test_z3c']
+
+    for test in tests:
+        setup = 'from __main__ import setup, %s; setup(); %s()' % (test, test)
+
+        t = timeit.Timer(setup=setup,
+                         stmt='%s()' % test)
+        time = t.timeit(number=number) / number
+
+        if time < 0.00001:
+            result = '   (not installed?)'
+        else:
+            result = '%16.2f ms' % (1000 * time)
+        print '%-35s %s' % (getattr(sys.modules[__name__], test).__doc__, result)
+
+
+if __name__ == '__main__':
+    which = None
+    if '-p' in sys.argv:
+        which = True
+        import hotshot, hotshot.stats
+        prof = hotshot.Profile("template.prof")
+        benchtime = prof.runcall(run, which, number=1)
+        stats = hotshot.stats.load("template.prof")
+        stats.strip_dirs()
+        stats.sort_stats('time', 'calls')
+        stats.print_stats()
+    else:
+        run(which, 1)


Property changes on: z3c.pt/trunk/benchmark/benchmark/bigtable.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: z3c.pt/trunk/buildout.cfg
===================================================================
--- z3c.pt/trunk/buildout.cfg	2008-07-17 19:44:22 UTC (rev 88464)
+++ z3c.pt/trunk/buildout.cfg	2008-07-17 20:51:51 UTC (rev 88465)
@@ -3,7 +3,7 @@
     .
     benchmark
 
-parts = test benchmark
+parts = test benchmark py
 find-links = http://download.zope.org/distribution/
 
 [test]
@@ -26,3 +26,10 @@
 Z3C_PT_DEBUG = False
 Z3C_PT_FILECACHE = ${buildout:directory}/cache
 zope_i18n_allowed_languages = en, da, de
+
+[py]
+recipe = zc.recipe.egg
+eggs = ${benchmark:eggs}
+interpreter = py
+environment = benchmark-environment
+scripts = py



More information about the Checkins mailing list