in reply to Re: RFC: Templating without a System
in thread RFC: Templating without a System
DOM parsing is costly, I have considered that approach, but I would do it only in the design phase of the application and deployment, or after changes made to some template, its to say I wouldn't use it as the page generating core.
I ran benchmark on a 5649 Byte html file with HTML::Seamstress and Servlet.
The only changes were uncomment use warnings because it clutters up the test with warnings about unitialized variables, and changed the warn "PROCESS_TREE: ", $tree->as_HTML; to a print statement.
No replace_content at all.
bench.pl:
gave the following results:#!/usr/bin/perl use lib "."; use Benchmark qw(:all) ; use Servlet qw(servlet); use example; # the spkg.pl generated package open(O,">/dev/null"); select O; # initialize some empty references I need in example.al my $freelist = []; my $list = []; my $in = {}; my $r = example->new; my $s = servlet( in => 'example.html', args => [ qw($nm $list $em8 $error $in $scopename $ref $res +ult $em26 $link $freelist $networkname $em14 $em9 %oui) ], ); my $count = 10000; my $results = timethese($count, { 'Seamstress' => sub { $r->process() }, 'Servlet' => sub { $s->($nm, $list, $em8, $error, $in, $scopena +me, $ref, $result, $em26, $link, $freelist, $networkname, $em14, $em9 +, %oui) }, }); select STDOUT; cmpthese($results);
I would replace_content with variable stubs and turn the resulting file inside out, as with my code.Rate Seamstress Servlet Seamstress 242/s -- -99% Servlet 47619/s 19548% --
greetings,
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: RFC: Templating without a System
by metaperl (Curate) on Jun 23, 2006 at 13:46 UTC | |
by shmem (Chancellor) on Jun 23, 2006 at 15:13 UTC |