Sunday, March 19, 2006

Speeding up ZPTs

I'm doing a bit of 'tinkering' again with some of my old Zope projects I have lying around.
I''ve written my own TAL engine, and I was testing it to see if it was any faster;
Using this template (thanks mcdonc d8), I ran a test using the venerable ab tool that comes with apache. Don't write in to tell me my hardware is crap, I know that, I don't performance test on high-performance hardware..

<html xmlns:tal="http://xml.zope.org/namespaces/tal">
<head>
<title>This is the title</title>
<div>This is the head slot</div>
</head>
<body tal:define="values python:[('bug', 'me'),]*20">
<div>
<span tal:replace="values" />
<form action="." method="POST">
<table border="0">
<tbody>
<tr tal:repeat="itemz values" class="foo">
<td tal:content="python: itemz[0]">Name</td>
<td tal:content="python: itemz[1]">Description</td>
</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>

The following are directly to Zope, not via apache.
First standard Page Templates;

Server Software: Zope/(Zope
Server Hostname: xanadu
Server Port: 8080

Document Path: /tmp/testTemplate2
Document Length: 2444 bytes

Concurrency Level: 10
Time taken for tests: 9.467635 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2651000 bytes
HTML transferred: 2444000 bytes
Requests per second: 105.62 [#/sec] (mean)
Time per request: 94.676 [ms] (mean)
Time per request: 9.468 [ms] (mean, across all concurrent requests)
Transfer rate: 273.35 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.8 0 9
Processing: 20 93 13.1 93 189
Waiting: 18 87 12.5 88 169
Total: 20 93 13.2 93 189

Percentage of the requests served within a certain time (ms)
50% 93
66% 94
75% 94
80% 94
90% 99
95% 105
98% 143
99% 150
100% 189 (longest request)
And now my Templates.

Server Software: Zope/(Zope
Server Hostname: xanadu
Server Port: 8080

Document Path: /tmp/testTemplate
Document Length: 2262 bytes

Concurrency Level: 10
Time taken for tests: 7.341181 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 2469000 bytes
HTML transferred: 2262000 bytes
Requests per second: 136.22 [#/sec] (mean)
Time per request: 73.412 [ms] (mean)
Time per request: 7.341 [ms] (mean, across all concurrent requests)
Transfer rate: 328.42 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.8 0 9
Processing: 23 72 13.6 72 170
Waiting: 21 66 12.7 67 130
Total: 23 72 13.6 72 170

Percentage of the requests served within a certain time (ms)
50% 72
66% 73
75% 73
80% 74
90% 87
95% 94
98% 107
99% 115
100% 170 (longest request)

30% faster, and that's a trivial page template. I need to find a less synthetic test, to do some 'real' testing and find out how much faster it really is, especially with METAL involved.
I can speed it up a little more too by sharing the 'cooking' between threads.

Anyhow stay tuned...

1 comment:

TJ said...

The compiled templates now run this test @ 142.25 requests / second.