annotate examples/bench/bigtable.py @ 828:eb8aa8690480 experimental-inline

inline branch: template object can be compiled, and remembers the generated module.
author cmlenz
date Fri, 13 Mar 2009 16:06:42 +0000
parents 8ebccfa9a9fe
children
rev   line source
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
1 # -*- encoding: utf-8 -*-
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
2 # Template language benchmarks
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
3 #
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
4 # Objective: Generate a 1000x10 HTML table as fast as possible.
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
5 #
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
6 # Author: Jonas Borgström <jonas@edgewall.com>
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
7
117
e51b81f1b5d5 Merged [141].
cmlenz
parents: 97
diff changeset
8 import cgi
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
9 import sys
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
10 import timeit
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
11 from StringIO import StringIO
826
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
12
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
13 from genshi.builder import tag
826
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
14 from genshi.core import Stream
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
15 from genshi.template import Context, MarkupTemplate, NewTextTemplate
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
16
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
17 try:
332
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
18 from elementtree import ElementTree as et
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
19 except ImportError:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
20 et = None
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
21
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
22 try:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
23 import cElementTree as cet
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
24 except ImportError:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
25 cet = None
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
26
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
27 try:
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
28 import neo_cgi, neo_cs, neo_util
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
29 except ImportError:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
30 neo_cgi = None
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
31
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
32 try:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
33 import kid
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
34 except ImportError:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
35 kid = None
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
36
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
37 try:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
38 from django.conf import settings
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
39 settings.configure()
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
40 from django.template import Context as DjangoContext
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
41 from django.template import Template as DjangoTemplate
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
42 except ImportError:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
43 DjangoContext = DjangoTemplate = None
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
44
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
45 try:
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
46 from mako.template import Template as MakoTemplate
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
47 except ImportError:
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
48 MakoTemplate = None
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
49
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
50 table = [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10)
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
51 for x in range(1000)]
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
52
233
7a426ab6407a * Added implementation of a simple text-based template engine. Closes #47.
cmlenz
parents: 230
diff changeset
53 genshi_tmpl = MarkupTemplate("""
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
54 <table xmlns:py="http://genshi.edgewall.org/">
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
55 <tr py:for="row in table">
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
56 <td py:for="c in row.values()" py:content="c"/>
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
57 </tr>
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
58 </table>
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
59 """)
828
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
60 genshi_tmpl_compiled = MarkupTemplate("""
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
61 <table xmlns:py="http://genshi.edgewall.org/">
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
62 <tr py:for="row in table">
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
63 <td py:for="c in row.values()" py:content="c"/>
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
64 </tr>
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
65 </table>
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
66 """).compile()
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
67
233
7a426ab6407a * Added implementation of a simple text-based template engine. Closes #47.
cmlenz
parents: 230
diff changeset
68 genshi_tmpl2 = MarkupTemplate("""
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
69 <table xmlns:py="http://genshi.edgewall.org/">$table</table>
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
70 """)
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
71
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
72 genshi_text_tmpl = NewTextTemplate("""
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
73 <table>
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
74 {% for row in table %}<tr>
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
75 {% for c in row.values() %}<td>$c</td>{% end %}
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
76 </tr>{% end %}
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
77 </table>
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
78 """)
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
79
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
80 if DjangoTemplate:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
81 django_tmpl = DjangoTemplate("""
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
82 <table>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
83 {% for row in table %}
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
84 <tr>{% for col in row.values %}{{ col|escape }}{% endfor %}</tr>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
85 {% endfor %}
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
86 </table>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
87 """)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
88
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
89 def test_django():
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
90 """Djange template"""
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
91 context = DjangoContext({'table': table})
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
92 django_tmpl.render(context)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
93
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
94 if MakoTemplate:
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
95 mako_tmpl = MakoTemplate("""
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
96 <table>
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
97 % for row in table:
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
98 <tr>
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
99 % for col in row.values():
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
100 <td>${ col | h }</td>
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
101 % endfor
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
102 </tr>
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
103 % endfor
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
104 </table>
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
105 """)
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
106 def test_mako():
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
107 """Mako Template"""
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
108 mako_tmpl.render(table=table)
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
109
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
110 def test_genshi():
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
111 """Genshi template"""
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
112 stream = genshi_tmpl.generate(table=table)
123
93bbdcf9428b Fix for #18: whitespace in space-sensitive elements such as `<pre>` and `<textarea>` is now preserved.
cmlenz
parents: 117
diff changeset
113 stream.render('html', strip_whitespace=False)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
114
826
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
115 def test_genshi_compiled():
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
116 """Genshi template, compiled to Python"""
828
eb8aa8690480 inline branch: template object can be compiled, and remembers the generated module.
cmlenz
parents: 826
diff changeset
117 stream = genshi_tmpl_compiled.generate(table=table)
826
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
118 stream.render('html', strip_whitespace=False)
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
119
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
120 def test_genshi_text():
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
121 """Genshi text template"""
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
122 stream = genshi_text_tmpl.generate(table=table)
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
123 stream.render('text')
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
124
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
125 def test_genshi_builder():
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
126 """Genshi template + tag builder"""
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
127 stream = tag.TABLE([
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
128 tag.tr([tag.td(c) for c in row.values()])
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
129 for row in table
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
130 ]).generate()
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
131 stream = genshi_tmpl2.generate(table=stream)
123
93bbdcf9428b Fix for #18: whitespace in space-sensitive elements such as `<pre>` and `<textarea>` is now preserved.
cmlenz
parents: 117
diff changeset
132 stream.render('html', strip_whitespace=False)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
133
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
134 def test_builder():
230
24757b771651 Renamed Markup to Genshi in repository.
cmlenz
parents: 149
diff changeset
135 """Genshi tag builder"""
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
136 stream = tag.TABLE([
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
137 tag.tr([
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
138 tag.td(c) for c in row.values()
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
139 ])
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
140 for row in table
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
141 ]).generate()
123
93bbdcf9428b Fix for #18: whitespace in space-sensitive elements such as `<pre>` and `<textarea>` is now preserved.
cmlenz
parents: 117
diff changeset
142 stream.render('html', strip_whitespace=False)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
143
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
144 if kid:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
145 kid_tmpl = kid.Template("""
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
146 <table xmlns:py="http://purl.org/kid/ns#">
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
147 <tr py:for="row in table">
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
148 <td py:for="c in row.values()" py:content="c"/>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
149 </tr>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
150 </table>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
151 """)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
152
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
153 kid_tmpl2 = kid.Template("""
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
154 <html xmlns:py="http://purl.org/kid/ns#">$table</html>
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
155 """)
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
156
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
157 def test_kid():
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
158 """Kid template"""
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
159 kid_tmpl.table = table
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
160 kid_tmpl.serialize(output='html')
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
161
332
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
162 if cet:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
163 def test_kid_et():
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
164 """Kid template + cElementTree"""
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
165 _table = cet.Element('table')
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
166 for row in table:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
167 td = cet.SubElement(_table, 'tr')
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
168 for c in row.values():
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
169 cet.SubElement(td, 'td').text=str(c)
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
170 kid_tmpl2.table = _table
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
171 kid_tmpl2.serialize(output='html')
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
172
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
173 if et:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
174 def test_et():
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
175 """ElementTree"""
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
176 _table = et.Element('table')
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
177 for row in table:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
178 tr = et.SubElement(_table, 'tr')
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
179 for c in row.values():
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
180 et.SubElement(tr, 'td').text=str(c)
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
181 et.tostring(_table)
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
182
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
183 if cet:
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
184 def test_cet():
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
185 """cElementTree"""
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
186 _table = cet.Element('table')
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
187 for row in table:
332
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
188 tr = cet.SubElement(_table, 'tr')
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
189 for c in row.values():
332
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
190 cet.SubElement(tr, 'td').text=str(c)
0e6ae0ade606 * Fixed `basic.py` benchmark on Windows, closing #72. Thanks to John M. Camara for reporting the issue and providing the fix.
cmlenz
parents: 319
diff changeset
191 cet.tostring(_table)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
192
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
193 if neo_cgi:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
194 def test_clearsilver():
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
195 """ClearSilver"""
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
196 hdf = neo_util.HDF()
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
197 for i, row in enumerate(table):
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
198 for j, c in enumerate(row.values()):
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
199 hdf.setValue("rows.%d.cell.%d" % (i, j), cgi.escape(str(c)))
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
200
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
201 cs = neo_cs.CS(hdf)
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
202 cs.parseStr("""
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
203 <table><?cs
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
204 each:row=rows
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
205 ?><tr><?cs each:c=row.cell
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
206 ?><td><?cs var:c ?></td><?cs /each
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
207 ?></tr><?cs /each?>
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
208 </table>""")
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
209 cs.render()
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
210
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
211
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
212 def run(which=None, number=10):
826
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
213 tests = ['test_builder', 'test_genshi', 'test_genshi_compiled',
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
214 'test_genshi_text', 'test_genshi_builder', 'test_mako',
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
215 'test_kid', 'test_kid_et', 'test_et', 'test_cet',
8ebccfa9a9fe inline branch: Add code block support to the template inliner, and some tweaks/cleanup.
cmlenz
parents: 820
diff changeset
216 'test_clearsilver', 'test_django']
319
2aa99bf95d84 Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents: 233
diff changeset
217
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
218 if which:
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
219 tests = filter(lambda n: n[5:] in which, tests)
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
220
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
221 for test in [t for t in tests if hasattr(sys.modules[__name__], t)]:
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
222 t = timeit.Timer(setup='from __main__ import %s;' % test,
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
223 stmt='%s()' % test)
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
224 time = t.timeit(number=number) / number
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
225
130
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
226 if time < 0.00001:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
227 result = ' (not installed?)'
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
228 else:
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
229 result = '%16.2f ms' % (1000 * time)
aa69c1f34a26 Added Django to the [wiki:MarkupPerformance#bigtablebenchmark bigtable benchmark], based on patch contributed by Simon Willison (#23). Also, changed the benchmark so that Clearsilver, Kid, and Django are not required to run the benchmark.
cmlenz
parents: 123
diff changeset
230 print '%-35s %s' % (getattr(sys.modules[__name__], test).__doc__, result)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
231
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
232
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
233 if __name__ == '__main__':
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
234 which = [arg for arg in sys.argv[1:] if arg[0] != '-']
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
235
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
236 if '-p' in sys.argv:
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
237 import cProfile, pstats
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
238 prof = cProfile.Profile()
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
239 prof.run('run(%r, number=1)' % which)
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
240 stats = pstats.Stats(prof)
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
241 stats.strip_dirs()
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
242 stats.sort_stats('time', 'calls')
820
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
243 stats.print_stats(25)
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
244 if '-v' in sys.argv:
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
245 stats.print_callees()
1837f39efd6f Sync (old) experimental inline branch with trunk@1027.
cmlenz
parents: 500
diff changeset
246 stats.print_callers()
97
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
247 else:
33fee66e0e8a Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff changeset
248 run(which)
Copyright (C) 2012-2017 Edgewall Software