Thread Template Toolkit: BLOCK + WRAPPER (14 answers)
Opened by bloonix at 2007-06-13 00:50

bloonix
 2007-06-13 02:15
#77468 #77468
User since
2005-12-17
1615 Artikel
HausmeisterIn
[Homepage]
user image
So, hier nochmal ganz simple... wenn du es mal ausprobieren möchtest...

index.tmpl
Code: (dl )
1
2
3
4
5
6
7
<html>
<head>
  <title></title>
</head>
<body>
</body>
</html>


test.pl
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use strict;
use warnings;
use Benchmark;
use Template;

open my $fh, '<', 'index.tmpl' or die $!;
my $template = do { local $/; <$fh> };
close $fh;

my $t1 = Template->new(INCLUDE_PATH => '.') or die $!;

sub program { $t1->process(\$template, undef, '/dev/null') or die $!; }
sub cache   { $t1->process('index.tmpl', undef, '/dev/null') or die $!; }

Benchmark::cmpthese(-1, {
  cache   => \&cache,
  program  => \&program,
});


         Rate program   cache
program 2277/s      --    -53%
cache   4886/s    115%      --
\n\n

<!--EDIT|opi|1181686528-->
What is a good module? That's hard to say.
What is good code? That's also hard to say.
One man's Thing of Beauty is another's man's Evil Hack.

View full thread Template Toolkit: BLOCK + WRAPPER