Hi Tobias,

Tobias Schlitt a écrit :
Hi,

On 10/09/2009 11:44 AM, Damien POBEL wrote:

Have you seen this benchmarks [1] between template engines on Fabien Potencier's blog ?

ezcTemplate components seems to be very far from others tested template engines in terms of performances (execution time and memory use).

as far as I understood the blog post, he only tested the first execution
of a template (namely the compilation phase). I think this number is
quite unisgnificant, since a template is only compiled once (on first
execution). More interessting would be, how fast the subsequent calls
are, since this gives an insight into performance of the compiled code
and therefore into the quality of the parser.

Parsing itself is a very memory consumpting process, if done correctly.

I'm curious about the benchmark. Please keep the list up2date when it's
available. Thanks!

Actually I tested a bit the code Fabien used for benchmarking and
I noticed that the template compiler generates a lot of syscalls.

If I got it correctly the process if the following :

1. initial call of ezcTemplate::process
2. inclusion of the compiled template
3. in the compiled template :
   1. call to ezcTemplateCompiledCode::checkRequirements
   2. call to ezcTemplate::process

etc, etc

The problem is that in both ezcTemplate::process and ezcTemplateCompiledCode
the same code is called :
if( file_exist(...) ... filemtime (...) < filemtime (...) )

If we take the use case of having 80 templates in a page, we can deduct the 
amount
of syscalls will increase quite quickly.

I also noticed that ezcTemplateCompiledCode::findCompiled is quite demanding as 
well.

So I wrote a simple patch, based upon ezcTemplate 1.4.1 (pear version) and I got
better results, it is of course not as fast as Twig I think, but if we can fix 
the
performance issues of that Component that is cool :)

A quick "before/after" :

Before
------
8:58 jer...@ezjr~/work/www/php5/ezcbench% time php somefile.php
php somefile.php  1.09s user 0.17s system 99% cpu 1.271 total

After
-----
9:00 jer...@ezjr~/work/www/php5/ezcbench% time php somefile.php
php somefile.php  0.84s user 0.14s system 99% cpu 0.988 total

This is of course not meant to be the miracle solution to any problem
but it would be interesting to decide if the patch is relevant or not.
I did not test it functionnaly, maybe we could try it on TheWire, for the
sake of curiosity :)

On a more functionnal side, I think we should provide a mean to instruct the 
Template
engine to recompile templates automatically or not, and provide sort of a 
client to
recompile outdated templates manually. This would save a lot of syscalls.

Attached :
- before.tar.gz : the number of syscalls before the patch
- after.tar.gz  : the number of syscalls after the patch
- compiled_code.diff.gz : the patch agains Template/compiled_code.php

Have a nice week-end.

Cheers :)

--
Jérôme Renard
j...@ez.no | eZ systems France | http://ez.no

Attachment: after.txt.gz
Description: GNU Zip compressed data

Attachment: before.txt.gz
Description: GNU Zip compressed data

Attachment: compiled_code.diff.gz
Description: GNU Zip compressed data

-- 
Components mailing list
Components@lists.ez.no
http://lists.ez.no/mailman/listinfo/components

Reply via email to