[Checkins] SVN: z3c.pt/trunk/ Slightly refactored benchmark tests
and added tests for the file variants.
Hanno Schlichting
plone at hannosch.info
Sat Jun 14 13:11:34 EDT 2008
Log message for revision 87394:
Slightly refactored benchmark tests and added tests for the file variants.
Changed:
A z3c.pt/trunk/benchmark/benchmark/input/
A z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_z3c.pt
A z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_zope.pt
U z3c.pt/trunk/benchmark/benchmark/tests.py
U z3c.pt/trunk/docs/HISTORY.txt
U z3c.pt/trunk/src/z3c/pt/template.py
-=-
Added: z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_z3c.pt
===================================================================
--- z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_z3c.pt (rev 0)
+++ z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_z3c.pt 2008-06-14 17:11:33 UTC (rev 87394)
@@ -0,0 +1,10 @@
+<table xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:tal="http://xml.zope.org/namespaces/tal">
+ <tr tal:repeat="row table">
+ <td tal:repeat="c row.values()">
+ <span tal:define="d c + 1"
+ tal:attributes="class 'column-' + str(d)"
+ tal:content="d" />
+ </td>
+ </tr>
+</table>
Property changes on: z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_z3c.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Added: z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_zope.pt
===================================================================
--- z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_zope.pt (rev 0)
+++ z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_zope.pt 2008-06-14 17:11:33 UTC (rev 87394)
@@ -0,0 +1,10 @@
+<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()">
+ <span tal:define="d python: c + 1"
+ tal:attributes="class python:'column-'+str(d)"
+ tal:content="d" />
+ </td>
+ </tr>
+</table>
Property changes on: z3c.pt/trunk/benchmark/benchmark/input/bigtable_python_zope.pt
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: z3c.pt/trunk/benchmark/benchmark/tests.py
===================================================================
--- z3c.pt/trunk/benchmark/benchmark/tests.py 2008-06-14 16:42:21 UTC (rev 87393)
+++ z3c.pt/trunk/benchmark/benchmark/tests.py 2008-06-14 17:11:33 UTC (rev 87394)
@@ -28,12 +28,21 @@
i += 1
t2 = time.time()
return 100*(t2-t1)/i
-
-class BenchmarkTestCase(unittest.TestCase):
+class BaseTestCase(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)]
+ def setUp(suite):
+ zope.component.testing.setUp(suite)
+ zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
+
+ def tearDown(suite):
+ zope.component.testing.tearDown(suite)
+
+class BenchmarkTestCase(BaseTestCase):
+
helloworld_z3c = z3c.pt.PageTemplate("""\
<div xmlns="http://www.w3.org/1999/xhtml">
Hello World!
@@ -96,13 +105,6 @@
</tr>
</table>""", 'text/xhtml')
- def setUp(suite):
- zope.component.testing.setUp(suite)
- zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
-
- def tearDown(suite):
- zope.component.testing.tearDown(suite)
-
@benchmark(u"Hello World")
def testHelloWorld(self):
t_z3c = timing(self.helloworld_z3c)
@@ -146,6 +148,29 @@
print " %.2fX" % (t_zope/t_z3c)
+class FileBenchmarkTestCase(BaseTestCase):
+
+ @benchmark(u"Big table (python) File")
+ def testBigTablePythonFile(self):
+ table = self.table
+
+ files = os.path.abspath(os.path.join(__file__, '..', 'input'))
+ def testfile(name):
+ return os.path.join(files, name)
+
+ z3cfile = z3c.pt.PageTemplateFile(
+ testfile('bigtable_python_z3c.pt'))
+
+ zopefile = zope.pagetemplate.pagetemplatefile.PageTemplateFile(
+ testfile('bigtable_python_zope.pt'))
+
+ t_z3c = timing(z3cfile.render, table=table)
+ t_zope = timing(zopefile, table=table)
+
+ print "z3c.pt: %.2f" % t_z3c
+ print "zope.pagetemplate: %.2f" % t_zope
+ print " %.2fX" % (t_zope/t_z3c)
+
# Use a custom context to add real i18n lookup
from zope.i18n import translate
@@ -171,11 +196,8 @@
return _getContext(engine, namespace)
-class I18NBenchmarkTestCase(unittest.TestCase):
+class I18NBenchmarkTestCase(BaseTestCase):
- 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)]
-
bigtable_i18n_z3c = z3c.pt.PageTemplate("""\
<table xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
@@ -211,13 +233,6 @@
</tr>
</table>""", 'text/xhtml')
- def setUp(suite):
- zope.component.testing.setUp(suite)
- zope.configuration.xmlconfig.XMLConfig('configure.zcml', z3c.pt)()
-
- def tearDown(suite):
- zope.component.testing.tearDown(suite)
-
@benchmark(u"Internationalization")
def testI18N(self):
table = self.table
@@ -232,6 +247,7 @@
def test_suite():
return unittest.TestSuite((
unittest.makeSuite(BenchmarkTestCase),
+ unittest.makeSuite(FileBenchmarkTestCase),
unittest.makeSuite(I18NBenchmarkTestCase),
))
Modified: z3c.pt/trunk/docs/HISTORY.txt
===================================================================
--- z3c.pt/trunk/docs/HISTORY.txt 2008-06-14 16:42:21 UTC (rev 87393)
+++ z3c.pt/trunk/docs/HISTORY.txt 2008-06-14 17:11:33 UTC (rev 87394)
@@ -4,6 +4,8 @@
Version 0.8.x
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+- Slightly refactored benchmark tests and added tests for the file variants.
+
- In debug mode the actual source code for file templates is written out to
a <filename>.source file, to make it easier to inspect it.
Modified: z3c.pt/trunk/src/z3c/pt/template.py
===================================================================
--- z3c.pt/trunk/src/z3c/pt/template.py 2008-06-14 16:42:21 UTC (rev 87393)
+++ z3c.pt/trunk/src/z3c/pt/template.py 2008-06-14 17:11:33 UTC (rev 87394)
@@ -87,6 +87,9 @@
class BaseTemplateFile(BaseTemplate):
def __init__(self, filename):
+ self.body = None
+ self.source = ''
+
if not os.path.isabs(filename):
package_name = sys._getframe(2).f_globals['__name__']
module = sys.modules[package_name]
@@ -101,7 +104,7 @@
# make sure file exists
os.lstat(filename)
self.filename = filename
-
+
def _get_filename(self):
return getattr(self, '_filename', None)
More information about the Checkins
mailing list