Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: I need to template this

by Rhandom (Curate)
on Apr 21, 2007 at 04:29 UTC ( [id://611260]=note: print w/replies, xml ) Need Help??


in reply to Re^4: I need to template this
in thread I need to template this

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.

The abreviations are as before but with the additions of CTX - CGI::Ex::Template::XS HTJ - HTML::Template::JIT TT_str 313/s -- -5% -60% -64% -69% -78% -80% -80% -83% -8 +4% -84% -87% -87% -88% -91% -91% -92% -95% -95% TTX_str 329/s 5% -- -58% -62% -67% -77% -79% -79% -82% -8 +3% -83% -86% -87% -88% -90% -91% -91% -95% -95% TT_compile 778/s 148% 136% -- -11% -23% -45% -50% -50% -57% -6 +0% -60% -67% -69% -71% -77% -78% -80% -87% -89% TTX_compile 872/s 178% 165% 12% -- -14% -39% -44% -44% -51% -5 +5% -55% -63% -65% -68% -74% -76% -77% -86% -87% HTE_str 1009/s 222% 207% 30% 16% -- -29% -35% -35% -44% -4 +8% -48% -57% -60% -63% -70% -72% -74% -84% -85% HT_str 1420/s 354% 332% 83% 63% 41% -- -9% -9% -21% -2 +6% -27% -39% -43% -47% -58% -61% -63% -77% -80% HTE_mem 1556/s 397% 373% 100% 78% 54% 10% -- -0% -13% -1 +9% -20% -34% -38% -42% -54% -57% -59% -75% -78% CET_str 1562/s 399% 375% 101% 79% 55% 10% 0% -- -13% -1 +9% -19% -33% -37% -42% -54% -57% -59% -75% -77% TextTemplate 1790/s 472% 444% 130% 105% 77% 26% 15% 15% -- - +7% -8% -23% -28% -34% -47% -50% -53% -71% -74% CTX_str 1930/s 516% 487% 148% 121% 91% 36% 24% 24% 8% +-- -0% -17% -23% -28% -43% -47% -50% -69% -72% HT_compile 1938/s 519% 489% 149% 122% 92% 37% 25% 24% 8% +0% -- -17% -22% -28% -43% -46% -49% -69% -72% TT_mem 2339/s 647% 611% 201% 168% 132% 65% 50% 50% 31% 2 +1% 21% -- -6% -13% -31% -35% -39% -62% -66% CET_compile 2497/s 698% 659% 221% 186% 148% 76% 61% 60% 40% 2 +9% 29% 7% -- -7% -26% -31% -35% -60% -64% HT_mem 2696/s 761% 719% 247% 209% 167% 90% 73% 73% 51% 4 +0% 39% 15% 8% -- -20% -25% -30% -56% -61% TTX_mem 3377/s 979% 927% 334% 287% 235% 138% 117% 116% 89% 7 +5% 74% 44% 35% 25% -- -7% -12% -45% -51% CTX_compile 3612/s 1054% 998% 364% 314% 258% 154% 132% 131% 102% 8 +7% 86% 54% 45% 34% 7% -- -6% -42% -48% CET_mem 3836/s 1125% 1066% 393% 340% 280% 170% 147% 146% 114% 9 +9% 98% 64% 54% 42% 14% 6% -- -38% -45% HTJ_compile 6193/s 1878% 1782% 696% 610% 514% 336% 298% 296% 246% 22 +1% 219% 165% 148% 130% 83% 71% 61% -- -11% CTX_mem 6934/s 2115% 2007% 791% 695% 587% 388% 346% 344% 287% 25 +9% 258% 196% 178% 157% 105% 92% 81% 12% --


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)];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://611260]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (4)
As of 2024-04-24 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found