Mercurial > genshi > mirror
annotate examples/bench/bigtable.py @ 891:f8bcd76729a1 trunk
Removed some obsolete/unused code from the i18n filter.
author | cmlenz |
---|---|
date | Wed, 21 Apr 2010 07:38:37 +0000 |
parents | bd1bed216344 |
children |
rev | line source |
---|---|
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
1 # -*- encoding: utf-8 -*- |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
2 # Template language benchmarks |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
3 # |
ff19219485cc
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. |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
5 # |
ff19219485cc
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> |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
7 |
117 | 8 import cgi |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
9 import sys |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
10 import timeit |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
11 from StringIO import StringIO |
230 | 12 from genshi.builder import tag |
592
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
13 from genshi.template import MarkupTemplate, NewTextTemplate |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
14 |
130
6edc71acb642
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
|
15 try: |
332
97b0d21b81b7
* 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
|
16 from elementtree import ElementTree as et |
97b0d21b81b7
* 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
|
17 except ImportError: |
97b0d21b81b7
* 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 et = None |
97b0d21b81b7
* 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 |
97b0d21b81b7
* 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 try: |
97b0d21b81b7
* 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 import cElementTree as cet |
97b0d21b81b7
* 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 except ImportError: |
97b0d21b81b7
* 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 cet = None |
97b0d21b81b7
* 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 |
97b0d21b81b7
* 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 try: |
130
6edc71acb642
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
|
26 import neo_cgi, neo_cs, neo_util |
6edc71acb642
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
|
27 except ImportError: |
6edc71acb642
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 neo_cgi = None |
6edc71acb642
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 |
6edc71acb642
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 try: |
6edc71acb642
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 import kid |
6edc71acb642
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 except ImportError: |
6edc71acb642
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 kid = None |
6edc71acb642
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 |
6edc71acb642
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 try: |
6edc71acb642
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 from django.conf import settings |
6edc71acb642
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 settings.configure() |
6edc71acb642
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.template import Context as DjangoContext |
6edc71acb642
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 from django.template import Template as DjangoTemplate |
6edc71acb642
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 except ImportError: |
6edc71acb642
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 DjangoContext = DjangoTemplate = None |
6edc71acb642
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 |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
43 try: |
543
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
44 from mako.template import Template as MakoTemplate |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
45 except ImportError: |
543
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
46 MakoTemplate = None |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
47 |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
48 table = [dict(a=1,b=2,c=3,d=4,e=5,f=6,g=7,h=8,i=9,j=10) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
49 for x in range(1000)] |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
50 |
233
88ec2b306296
* Added implementation of a simple text-based template engine. Closes #47.
cmlenz
parents:
230
diff
changeset
|
51 genshi_tmpl = MarkupTemplate(""" |
230 | 52 <table xmlns:py="http://genshi.edgewall.org/"> |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
53 <tr py:for="row in table"> |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
54 <td py:for="c in row.values()" py:content="c"/> |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
55 </tr> |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
56 </table> |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
57 """) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
58 |
233
88ec2b306296
* Added implementation of a simple text-based template engine. Closes #47.
cmlenz
parents:
230
diff
changeset
|
59 genshi_tmpl2 = MarkupTemplate(""" |
230 | 60 <table xmlns:py="http://genshi.edgewall.org/">$table</table> |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
61 """) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
62 |
592
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
63 genshi_text_tmpl = NewTextTemplate(""" |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
64 <table> |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
65 {% for row in table %}<tr> |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
66 {% for c in row.values() %}<td>$c</td>{% end %} |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
67 </tr>{% end %} |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
68 </table> |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
69 """) |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
70 |
130
6edc71acb642
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
|
71 if DjangoTemplate: |
6edc71acb642
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
|
72 django_tmpl = DjangoTemplate(""" |
6edc71acb642
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
|
73 <table> |
6edc71acb642
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
|
74 {% for row in table %} |
6edc71acb642
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
|
75 <tr>{% for col in row.values %}{{ col|escape }}{% endfor %}</tr> |
6edc71acb642
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
|
76 {% endfor %} |
6edc71acb642
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
|
77 </table> |
6edc71acb642
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
|
78 """) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
79 |
130
6edc71acb642
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 def test_django(): |
6edc71acb642
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 """Djange template""" |
6edc71acb642
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 context = DjangoContext({'table': table}) |
6edc71acb642
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 django_tmpl.render(context) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
84 |
543
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
85 if MakoTemplate: |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
86 mako_tmpl = MakoTemplate(""" |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
87 <table> |
543
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
88 % for row in table: |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
89 <tr> |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
90 % for col in row.values(): |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
91 <td>${ col | h }</td> |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
92 % endfor |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
93 </tr> |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
94 % endfor |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
95 </table> |
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
96 """) |
543
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
97 def test_mako(): |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
98 """Mako Template""" |
0449396999c5
Replace Myghty by Mako in bigtable benchmark, apply escaping in Mako templates.
cmlenz
parents:
487
diff
changeset
|
99 mako_tmpl.render(table=table) |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
100 |
230 | 101 def test_genshi(): |
102 """Genshi template""" | |
103 stream = genshi_tmpl.generate(table=table) | |
123
10279d2eeec9
Fix for #18: whitespace in space-sensitive elements such as `<pre>` and `<textarea>` is now preserved.
cmlenz
parents:
117
diff
changeset
|
104 stream.render('html', strip_whitespace=False) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
105 |
592
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
106 def test_genshi_text(): |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
107 """Genshi text template""" |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
108 stream = genshi_text_tmpl.generate(table=table) |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
109 stream.render('text') |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
110 |
230 | 111 def test_genshi_builder(): |
112 """Genshi template + tag builder""" | |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
113 stream = tag.TABLE([ |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
114 tag.tr([tag.td(c) for c in row.values()]) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
115 for row in table |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
116 ]).generate() |
230 | 117 stream = genshi_tmpl2.generate(table=stream) |
123
10279d2eeec9
Fix for #18: whitespace in space-sensitive elements such as `<pre>` and `<textarea>` is now preserved.
cmlenz
parents:
117
diff
changeset
|
118 stream.render('html', strip_whitespace=False) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
119 |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
120 def test_builder(): |
230 | 121 """Genshi tag builder""" |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
122 stream = tag.TABLE([ |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
123 tag.tr([ |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
124 tag.td(c) for c in row.values() |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
125 ]) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
126 for row in table |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
127 ]).generate() |
123
10279d2eeec9
Fix for #18: whitespace in space-sensitive elements such as `<pre>` and `<textarea>` is now preserved.
cmlenz
parents:
117
diff
changeset
|
128 stream.render('html', strip_whitespace=False) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
129 |
130
6edc71acb642
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
|
130 if kid: |
6edc71acb642
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
|
131 kid_tmpl = kid.Template(""" |
6edc71acb642
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
|
132 <table xmlns:py="http://purl.org/kid/ns#"> |
6edc71acb642
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
|
133 <tr py:for="row in table"> |
6edc71acb642
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
|
134 <td py:for="c in row.values()" py:content="c"/> |
6edc71acb642
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
|
135 </tr> |
6edc71acb642
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
|
136 </table> |
6edc71acb642
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
|
137 """) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
138 |
130
6edc71acb642
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
|
139 kid_tmpl2 = kid.Template(""" |
6edc71acb642
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
|
140 <html xmlns:py="http://purl.org/kid/ns#">$table</html> |
6edc71acb642
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
|
141 """) |
6edc71acb642
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
|
142 |
6edc71acb642
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
|
143 def test_kid(): |
6edc71acb642
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 """Kid template""" |
6edc71acb642
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.table = table |
6edc71acb642
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 kid_tmpl.serialize(output='html') |
6edc71acb642
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 |
332
97b0d21b81b7
* 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
|
148 if cet: |
97b0d21b81b7
* 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
|
149 def test_kid_et(): |
97b0d21b81b7
* 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
|
150 """Kid template + cElementTree""" |
97b0d21b81b7
* 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
|
151 _table = cet.Element('table') |
97b0d21b81b7
* 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
|
152 for row in table: |
97b0d21b81b7
* 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
|
153 td = cet.SubElement(_table, 'tr') |
97b0d21b81b7
* 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
|
154 for c in row.values(): |
97b0d21b81b7
* 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
|
155 cet.SubElement(td, 'td').text=str(c) |
97b0d21b81b7
* 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
|
156 kid_tmpl2.table = _table |
97b0d21b81b7
* 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
|
157 kid_tmpl2.serialize(output='html') |
97b0d21b81b7
* 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
|
158 |
97b0d21b81b7
* 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
|
159 if et: |
97b0d21b81b7
* 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
|
160 def test_et(): |
97b0d21b81b7
* 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
|
161 """ElementTree""" |
97b0d21b81b7
* 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 _table = et.Element('table') |
97b0d21b81b7
* 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 for row in table: |
97b0d21b81b7
* 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 tr = et.SubElement(_table, 'tr') |
97b0d21b81b7
* 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 for c in row.values(): |
97b0d21b81b7
* 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 et.SubElement(tr, 'td').text=str(c) |
97b0d21b81b7
* 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 et.tostring(_table) |
97b0d21b81b7
* 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 |
97b0d21b81b7
* 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 if cet: |
97b0d21b81b7
* 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 def test_cet(): |
97b0d21b81b7
* 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 """cElementTree""" |
130
6edc71acb642
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
|
172 _table = cet.Element('table') |
6edc71acb642
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
|
173 for row in table: |
332
97b0d21b81b7
* 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 tr = cet.SubElement(_table, 'tr') |
130
6edc71acb642
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
|
175 for c in row.values(): |
332
97b0d21b81b7
* 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 cet.SubElement(tr, 'td').text=str(c) |
97b0d21b81b7
* 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 cet.tostring(_table) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
178 |
130
6edc71acb642
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
|
179 if neo_cgi: |
6edc71acb642
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
|
180 def test_clearsilver(): |
6edc71acb642
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
|
181 """ClearSilver""" |
6edc71acb642
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
|
182 hdf = neo_util.HDF() |
6edc71acb642
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
|
183 for i, row in enumerate(table): |
6edc71acb642
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
|
184 for j, c in enumerate(row.values()): |
6edc71acb642
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
|
185 hdf.setValue("rows.%d.cell.%d" % (i, j), cgi.escape(str(c))) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
186 |
130
6edc71acb642
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 cs = neo_cs.CS(hdf) |
6edc71acb642
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
|
188 cs.parseStr(""" |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
189 <table><?cs |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
190 each:row=rows |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
191 ?><tr><?cs each:c=row.cell |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
192 ?><td><?cs var:c ?></td><?cs /each |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
193 ?></tr><?cs /each?> |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
194 </table>""") |
130
6edc71acb642
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 cs.render() |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
196 |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
197 |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
198 def run(which=None, number=10): |
592
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
199 tests = ['test_builder', 'test_genshi', 'test_genshi_text', |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
200 'test_genshi_builder', 'test_mako', 'test_kid', 'test_kid_et', |
1da8de3e5e51
Add a new syntax for text templates, which is available alongside the old syntax for now. The new syntax is more poweful and flexible, using Django-style directive notation.
cmlenz
parents:
543
diff
changeset
|
201 'test_et', 'test_cet', 'test_clearsilver', 'test_django'] |
319
bab19496d4fa
Add [http://www.myghty.org/ Myghty] to the benchmarks, kindly contributed by Mike Bayer.
cmlenz
parents:
233
diff
changeset
|
202 |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
203 if which: |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
204 tests = filter(lambda n: n[5:] in which, tests) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
205 |
130
6edc71acb642
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
|
206 for test in [t for t in tests if hasattr(sys.modules[__name__], t)]: |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
207 t = timeit.Timer(setup='from __main__ import %s;' % test, |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
208 stmt='%s()' % test) |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
209 time = t.timeit(number=number) / number |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
210 |
130
6edc71acb642
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
|
211 if time < 0.00001: |
6edc71acb642
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
|
212 result = ' (not installed?)' |
6edc71acb642
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
|
213 else: |
6edc71acb642
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
|
214 result = '%16.2f ms' % (1000 * time) |
6edc71acb642
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
|
215 print '%-35s %s' % (getattr(sys.modules[__name__], test).__doc__, result) |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
216 |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
217 |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
218 if __name__ == '__main__': |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
219 which = [arg for arg in sys.argv[1:] if arg[0] != '-'] |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
220 |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
221 if '-p' in sys.argv: |
815 | 222 import cProfile, pstats |
223 prof = cProfile.Profile() | |
224 prof.run('run(%r, number=1)' % which) | |
225 stats = pstats.Stats(prof) | |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
226 stats.strip_dirs() |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
227 stats.sort_stats('time', 'calls') |
815 | 228 stats.print_stats(25) |
229 if '-v' in sys.argv: | |
230 stats.print_callees() | |
231 stats.print_callers() | |
97
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
232 else: |
ff19219485cc
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
233 run(which) |