Hey,
So, I implemented the template caching you described, in fact I
"borrowed" some code from TG2 (much of which I wrote) and put it into
tw2. I was getting sort of poor results, so I dug deeper to find
TableLayout was a genshi template, so genshi was still rendering!!!
Once I got that outta there, the results were awesome. I was able to
achieve a 2x speedup, or 81 r/sec, for 10 textfields per form. This
is a marked improvement.
So, either TW is still rendering with genshi somewhere, or this is an
excellent improvement over TW1. Here is what my root controller
widget looks like:
class MyTableLayout(twf.TableLayout):
template = "mako:tw2test.templates.table_layout"
#mako-ize the templates
class MyTW2Form(twf.TableForm):
template = "mako:tw2test.templates.form"
child = twc.Variable(default=MyTableLayout)
class MyTW2TextField(twf.widgets.TextField):
template = "mako:tw2test.templates.input_field"
n = 10
def TW2FormBuilder(n):
class NewForm(MyTW2Form):
children = [MyTW2TextField(id='input%s'%i) for i in range(n)]
return NewForm
MyTW2Form = TW2FormBuilder(n)
and my TableLayout template:
<table>
<tr py:for="i,c in enumerate(w.children_non_hidden)" class="${(i %
2 and 'even' or 'odd') + ((c.validator and c.validator.required) and '
required' or '') + (c.error_msg and ' error' or '')}" title="$
{w.hover_help and c.help_text or None}" py:attrs="c.container_attrs"
id="${c.compound_id}:container">
<th py:if="c.label">$c.label</th>
<td py:attrs="None if c.label else dict(colspan='2')">
${c.display()}
<py:if test="not w.hover_help">$c.help_text</py:if>
<span id="${c.compound_id}:error" py:content="c.error_msg"/
>
</td>
</tr>
<tr class="error"><td colspan="2">
<py:for each="c in w.children_hidden">${c.display()}</py:for>
<span id="${w.compound_id}:error" py:content="w.error_msg"/>
</td></tr>
</table>
And the results:
ab -c 3 -n 1000
http://127.0.0.1:8080/tw2
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd,
http://www.zeustech.net/
Licensed to The Apache Software Foundation,
http://www.apache.org/
Benchmarking 127.0.0.1 (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests
Server Software: PasteWSGIServer/0.5
Server Hostname: 127.0.0.1
Server Port: 8080
Document Path: /tw2
Document Length: 2782 bytes
Concurrency Level: 3
Time taken for tests: 12.264 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2985000 bytes
HTML transferred: 2782000 bytes
Requests per second: 81.54 [#/sec] (mean)
Time per request: 36.793 [ms] (mean)
Time per request: 12.264 [ms] (mean, across all concurrent
requests)
Transfer rate: 237.69 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.6 0 6
Processing: 10 36 19.2 33 146
Waiting: 1 29 16.0 26 131
Total: 10 37 19.2 33 146
Percentage of the requests served within a certain time (ms)
50% 33
66% 40
75% 46
80% 51
90% 61
95% 71
98% 85
99% 102
100% 146 (longest request)
I'm going to crank on this some more and maybe convert sprox over to
it. Nice work Paul.
cheers.
-chris