Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Re^5: I need to template thisby Rhandom (Curate) |
on Apr 21, 2007 at 04:29 UTC ( [id://611260]=note: print w/replies, xml ) | Need Help?? |
Would've had results sooner - but I had to run an errand.
I added HTML::Template::JIT to the tests. I also added CGI::Ex::Template::XS which I wrote last August - I haven't released it yet because there are two memory leaks in some obscure TT filter operations - and because I haven't seen that much interest. The results are below - I've tried to compact the thing down.
So - H::T::JIT is very very very fast. Faster than just about anything else. It also is nice because it doesn't have to stay resident in memory to give a speed boost. You just compile the template to c and run it from scratch each time (unlike the CTX_mem test that was faster - but had to keep the compiled template in memory such as you would do with mod_perl). The downside to H::T::JIT is that there is no expression support (I hate to fan the expression/no-expression fire - but most people I work or talk with use expressions in their templates - but we're talking a couple dozen people at most). Someday - I'd really love to have a module that compiled the templates down to Parrot bytecode - once - and then executed them - or even better JITed them and then executed them. I think Parrot based templates would fly because you could avoid the costly process of jumping from Perl to C and back - you'd stay in the Parrot interpreter. If we don't do (or even if we did do) the parrot version, then at minimum I'd love to see a "common compiled template" format that was able to suit all of the various template engines. I think my parsed optree comes pretty close to being suitable - but it certainly isn't commonly used. With a little more massaging, my current format could be stored language agnostic as JSON or some other low level type. This would make life easier for the Jemplate guys - and it would also help out the Python guys who are currently trying to make version of TT in python. We could all share a common compiled template between the languages and various template syntaxes and create "the one true executor" in each language - possibly with an extensible c based library used by each language. OK - now I'm rambling. Not that you'd be interested (but if you are) - it would be relatively easy to create HTML::Template::TT based on HTML::Template and the parse_expr and play_expr methods of CGI::Ex::Template that would offer TT style expression support in HTML::Templates. It could even go a little farther and compile the HTML::Template to the opcode tree that I use - at which point it could be cached as a CGI::Ex::Template pre-compiled template. I have though about this recently as I've been maintaining some HTML::Template::Expr templates. Just a thought.
my @a=qw(random brilliant braindead); print $a[rand(@a)];
In Section
Seekers of Perl Wisdom
|
|