Mercurial > genshi > genshi-test
annotate examples/bench/bigtable.py @ 97:33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
author | cmlenz |
---|---|
date | Fri, 21 Jul 2006 11:56:01 +0000 |
parents | |
children | e51b81f1b5d5 |
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 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
8 import sys |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
9 import timeit |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
10 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
11 import cElementTree as cet |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
12 from elementtree import ElementTree as et |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
13 import kid |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
14 from markup.builder import tag |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
15 from markup.template import Context, Template |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
16 import neo_cgi |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
17 import neo_cs |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
18 import neo_util |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
19 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
20 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
|
21 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
|
22 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
23 markup_tmpl = Template(""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
24 <table xmlns:py="http://markup.edgewall.org/"> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
25 <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
|
26 <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
|
27 </tr> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
28 </table> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
29 """) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
30 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
31 markup_tmpl2 = Template(""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
32 <table xmlns:py="http://markup.edgewall.org/">$table</table> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
33 """) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
34 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
35 kid_tmpl = kid.Template(""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
36 <table xmlns:py="http://purl.org/kid/ns#"> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
37 <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
|
38 <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
|
39 </tr> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
40 </table> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
41 """) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
42 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
43 kid_tmpl2 = kid.Template(""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
44 <html xmlns:py="http://purl.org/kid/ns#">$table</html> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
45 """) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
46 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
47 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
48 def test_markup(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
49 """Markup template""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
50 ctxt = Context(table=table) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
51 stream = markup_tmpl.generate(ctxt) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
52 stream.render('html') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
53 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
54 def test_markup_builder(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
55 """Markup template + tag builder""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
56 stream = tag.TABLE([ |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
57 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
|
58 for row in table |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
59 ]).generate() |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
60 ctxt = Context(table=stream) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
61 stream = markup_tmpl2.generate(ctxt) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
62 stream.render('html') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
63 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
64 def test_builder(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
65 """Markup tag builder""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
66 stream = tag.TABLE([ |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
67 tag.tr([ |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
68 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
|
69 ]) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
70 for row in table |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
71 ]).generate() |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
72 stream.render('html') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
73 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
74 def test_kid(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
75 """Kid template""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
76 kid_tmpl.table = table |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
77 kid_tmpl.serialize(output='html') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
78 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
79 def test_kid_et(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
80 """Kid template + cElementTree""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
81 _table = cet.Element('table') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
82 for row in table: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
83 td = cet.SubElement(_table, 'tr') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
84 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
|
85 cet.SubElement(td, 'td').text=str(c) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
86 kid_tmpl2.table = _table |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
87 kid_tmpl2.serialize(output='html') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
88 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
89 def test_et(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
90 """ElementTree""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
91 _table = et.Element('table') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
92 for row in table: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
93 tr = et.SubElement(_table, 'tr') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
94 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
|
95 et.SubElement(tr, 'td').text=str(c) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
96 et.tostring(_table) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
97 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
98 def test_cet(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
99 """cElementTree""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
100 _table = cet.Element('table') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
101 for row in table: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
102 tr = cet.SubElement(_table, 'tr') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
103 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
|
104 cet.SubElement(tr, 'td').text=str(c) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
105 cet.tostring(_table) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
106 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
107 def test_clearsilver(): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
108 """ClearSilver""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
109 hdf = neo_util.HDF() |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
110 for i, row in enumerate(table): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
111 for j, c in enumerate(row.values()): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
112 hdf.setValue("rows.%d.cell.%d" % (i, j), str(c)) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
113 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
114 cs = neo_cs.CS(hdf) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
115 cs.parseStr(""" |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
116 <table><?cs |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
117 each:row=rows |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
118 ?><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
|
119 ?><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
|
120 ?></tr><?cs /each?> |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
121 </table>""") |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
122 cs.render() |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
123 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
124 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
125 def run(which=None, number=10): |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
126 tests = ['test_builder', 'test_markup', 'test_markup_builder', 'test_kid', |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
127 'test_kid_et', 'test_et', 'test_cet', 'test_clearsilver'] |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
128 if which: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
129 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
|
130 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
131 for test in tests: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
132 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
|
133 stmt='%s()' % test) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
134 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
|
135 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
136 print '%-35s %8.2f ms' % (getattr(sys.modules[__name__], test).__doc__, |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
137 1000 * time) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
138 |
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 if __name__ == '__main__': |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
141 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
|
142 |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
143 if '-p' in sys.argv: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
144 import hotshot, hotshot.stats |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
145 prof = hotshot.Profile("template.prof") |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
146 benchtime = prof.runcall(run, which, number=1) |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
147 stats = hotshot.stats.load("template.prof") |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
148 stats.strip_dirs() |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
149 stats.sort_stats('time', 'calls') |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
150 stats.print_stats() |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
151 else: |
33fee66e0e8a
Add benchmark that builds a large HTML table using different templating techniques (provided by Jonas).
cmlenz
parents:
diff
changeset
|
152 run(which) |