[Checkins] SVN: z3c.pt/trunk/ Added simple benchmark test for i18n handling.

Hanno Schlichting plone at hannosch.info
Sat Jun 14 06:46:37 EDT 2008


Log message for revision 87390:
  Added simple benchmark test for i18n handling.
  

Changed:
  U   z3c.pt/trunk/benchmark/benchmark/tests.py
  U   z3c.pt/trunk/docs/HISTORY.txt

-=-
Modified: z3c.pt/trunk/benchmark/benchmark/tests.py
===================================================================
--- z3c.pt/trunk/benchmark/benchmark/tests.py	2008-06-14 09:56:59 UTC (rev 87389)
+++ z3c.pt/trunk/benchmark/benchmark/tests.py	2008-06-14 10:46:37 UTC (rev 87390)
@@ -30,6 +30,10 @@
     return 100*(t2-t1)/i
            
 class BenchmarkTestCase(unittest.TestCase):
+
+    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)]
+
     helloworld_z3c = z3c.pt.PageTemplate("""\
     <div xmlns="http://www.w3.org/1999/xhtml">
     Hello World!
@@ -66,6 +70,21 @@
     </tr>
     </table>""")
 
+    bigtable_i18n_z3c = z3c.pt.PageTemplate("""\
+    <table xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+    xmlns:tal="http://xml.zope.org/namespaces/tal">
+    <tr tal:repeat="row table">
+    <span i18n:translate="label_default">Default</span>
+    <td tal:repeat="c row.values()">
+    <span tal:define="d c + 1"
+    tal:attributes="class 'column-' + str(d)"
+    tal:content="d" i18n:attributes="class" />
+    <span i18n:translate="">Default</span>
+    </td>
+    </tr>
+    </table>""")
+
     bigtable_python_zope = zope.pagetemplate.pagetemplate.PageTemplate()
     bigtable_python_zope.pt_edit("""\
     <table xmlns="http://www.w3.org/1999/xhtml"
@@ -92,6 +111,22 @@
     </tr>
     </table>""", 'text/xhtml')
 
+    bigtable_i18n_zope = zope.pagetemplate.pagetemplate.PageTemplate()
+    bigtable_i18n_zope.pt_edit("""\
+    <table xmlns="http://www.w3.org/1999/xhtml"
+    xmlns:i18n="http://xml.zope.org/namespaces/i18n"
+    xmlns:tal="http://xml.zope.org/namespaces/tal">
+    <tr tal:repeat="row python: options['table']">
+    <span i18n:translate="label_default">Default</span>
+    <td tal:repeat="c python: row.values()">
+    <span tal:define="d python: c + 1"
+    tal:attributes="class python:'column-'+str(d)"
+    tal:content="d" i18n:attributes="class" />
+    <span i18n:translate="">Default</span>
+    </td>
+    </tr>
+    </table>""", 'text/xhtml')
+
     def setUp(suite):
         zope.component.testing.setUp(suite)
         zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
@@ -110,8 +145,7 @@
 
     @benchmark(u"Big table (python)")
     def testBigTablePython(self):
-        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)]
+        table = self.table
 
         t_z3c = timing(self.bigtable_python_z3c, table=table)
         t_zope = timing(self.bigtable_python_zope, table=table)
@@ -122,8 +156,7 @@
 
     @benchmark(u"Big table (path)")
     def testBigTablePath(self):
-        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)]
+        table = self.table
 
         t_z3c = timing(self.bigtable_path_z3c, table=table, request=object())
         t_zope = timing(self.bigtable_path_zope, table=table)
@@ -134,8 +167,7 @@
 
     @benchmark(u"Compilation")
     def testCompilation(self):
-        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)]
+        table = self.table
 
         t_z3c = timing(self.bigtable_python_z3c.cook, ['table'])
         t_zope = timing(self.bigtable_python_zope._cook)
@@ -144,6 +176,17 @@
         print "zope.pagetemplate: %.2f" % t_zope
         print "                   %.2fX" % (t_zope/t_z3c)
 
+    @benchmark(u"Internationalization")
+    def testI18N(self):
+        table = self.table
+
+        t_z3c = timing(self.bigtable_i18n_z3c, table=table)
+        t_zope = timing(self.bigtable_i18n_zope, table=table)
+
+        print "z3c.pt:            %.2f" % t_z3c
+        print "zope.pagetemplate: %.2f" % t_zope
+        print "                   %.2fX" % (t_zope/t_z3c)
+
 def test_suite():
     return unittest.makeSuite(BenchmarkTestCase)
 

Modified: z3c.pt/trunk/docs/HISTORY.txt
===================================================================
--- z3c.pt/trunk/docs/HISTORY.txt	2008-06-14 09:56:59 UTC (rev 87389)
+++ z3c.pt/trunk/docs/HISTORY.txt	2008-06-14 10:46:37 UTC (rev 87390)
@@ -4,6 +4,8 @@
 Version 0.8.x
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+- Added simple benchmark test for i18n handling.
+
 - Added more tests for i18n attributes handling.
 
 - Don't generate empty mappings for expressions with a trailing semicolon.



More information about the Checkins mailing list