Apache/2.4.7 (Ubuntu) Linux sman1baleendah 3.13.0-24-generic #46-Ubuntu SMP Thu Apr 10 19:11:08 UTC 2014 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) safemode : OFF MySQL: ON | Perl: ON | cURL: OFF | WGet: ON > / usr / share / doc / libhtml-template-perl / examples / | server ip : 172.67.156.115 your ip : 172.70.80.62 H O M E |
Filename | /usr/share/doc/libhtml-template-perl/examples/time_trial.pl |
Size | 3.62 kb |
Permission | rwxr-xr-x |
Owner | root : root |
Create time | 27-Apr-2025 10:11 |
Last modified | 22-Oct-2013 01:27 |
Last accessed | 07-Jul-2025 02:17 |
Actions | edit | rename | delete | download (gzip) |
View | text | code | image |
#!/usr/bin/env perl
use strict;
use warnings;
use lib '../lib';
use HTML::Template;
# this is a little script I use to test the timing behavior of various
# options in HTML::Template;;
# an array of template files to test against and params to fill in
my %templates = (
simple => ['templates/simple.tmpl', {}],
include => ['templates/include.tmpl'],
medium => [
'templates/medium.tmpl',
{
'ALERT' => 'I am alert.',
'COMPANY_NAME' => "MY NAME IS",
'COMPANY_ID' => "10001",
'OFFICE_ID' => "10103214",
'NAME' => 'SAM I AM',
'ADDRESS' => '101011 North Something Something',
'CITY' => 'NEW York',
'STATE' => 'NEw York',
'ZIP' => '10014',
'PHONE' => '212-929-4315',
'PHONE2' => '',
'SUBCATEGORIES' => 'kfldjaldsf',
'DESCRIPTION' =>
"dsa;kljkldasfjkldsajflkjdsfklfjdsgkfld\nalskdjklajsdlkajfdlkjsfd\n\talksjdklajsfdkljdsf\ndsa;klfjdskfj",
'WEBSITE' => 'http://www.assforyou.com/',
'INTRANET_URL' => 'http://www.something.com',
'REMOVE_BUTTON' => "<INPUT TYPE=SUBMIT NAME=command VALUE=\"Remove Office\">",
'COMPANY_ADMIN_AREA' =>
"<A HREF=administrator.cgi?office_id=office_id&command=manage>Manage Office Administrators</A>",
'CASESTUDIES_LIST' =>
"adsfkljdskldszfgfdfdsgdsfgfdshghdmfldkgjfhdskjfhdskjhfkhdsakgagsfjhbvdsaj hsgbf jhfg sajfjdsag ffasfj hfkjhsdkjhdsakjfhkj kjhdsfkjhdskfjhdskjfkjsda kjjsafdkjhds kjds fkj skjh fdskjhfkj kj kjhf kjh sfkjhadsfkj hadskjfhkjhs ajhdsfkj akj fkj kj kj kkjdsfhk skjhadskfj haskjh fkjsahfkjhsfk ksjfhdkjh sfkjhdskjfhakj shiou weryheuwnjcinuc 3289u4234k 5 i 43iundsinfinafiunai saiufhiudsaf afiuhahfwefna uwhf u auiu uh weiuhfiuh iau huwehiucnaiuncianweciuninc iuaciun iucniunciunweiucniuwnciwe",
'NUMBER_OF_CONTACTS' => "aksfjdkldsajfkljds",
'COUNTRY_SELECTOR' => "klajslkjdsafkljds",
'LOGO_LINK' => "dsfpkjdsfkgljdsfkglj",
'PHOTO_LINK' => "lsadfjlkfjdsgkljhfgklhasgh",
}
],
long_loop => ['templates/long_loops.tmpl', {}],
loop_if => ['templates/loop-if.tmpl', {LOOP_ONE => [{VAR => 'foo'}]}]
);
# a hash of option hashes to test
my %options = (
'no cache' => {},
#'simple cache' => { cache => 1 },
# 'shared cache' => { shared_cache => 1, cache => 1 },
'file cache' => {
file_cache => 1,
file_cache_dir => './file_cache'
},
# 'simple cache, no_includes' => { cache => 1, no_includes => 1},
# 'blind cache' => { blind_cache => 1},
);
# number of times over each template
my $n = 100;
#open(OUT, ">test.out");
foreach my $template (keys %templates) {
print "\nTESTING : $template : $n iterations\n\n";
foreach my $option (keys %options) {
my $start_time = (times)[0];
for (my $x = 0 ; $x < $n ; $x++) {
my $template = HTML::Template->new(
filename => $templates{$template}->[0],
%{$options{$option}}
);
foreach my $name (keys %{$templates{$template}->[1]}) {
$template->param($name => $templates{$template}->[1]->{$name});
}
my $result = $template->output;
#print OUT $result;
#$template->output(print_to => *OUT);
}
my $end_time = (times)[0];
print "$option : average iteration in " . (($end_time - $start_time) / $n) . " seconds\n";
}
}
use strict;
use warnings;
use lib '../lib';
use HTML::Template;
# this is a little script I use to test the timing behavior of various
# options in HTML::Template;;
# an array of template files to test against and params to fill in
my %templates = (
simple => ['templates/simple.tmpl', {}],
include => ['templates/include.tmpl'],
medium => [
'templates/medium.tmpl',
{
'ALERT' => 'I am alert.',
'COMPANY_NAME' => "MY NAME IS",
'COMPANY_ID' => "10001",
'OFFICE_ID' => "10103214",
'NAME' => 'SAM I AM',
'ADDRESS' => '101011 North Something Something',
'CITY' => 'NEW York',
'STATE' => 'NEw York',
'ZIP' => '10014',
'PHONE' => '212-929-4315',
'PHONE2' => '',
'SUBCATEGORIES' => 'kfldjaldsf',
'DESCRIPTION' =>
"dsa;kljkldasfjkldsajflkjdsfklfjdsgkfld\nalskdjklajsdlkajfdlkjsfd\n\talksjdklajsfdkljdsf\ndsa;klfjdskfj",
'WEBSITE' => 'http://www.assforyou.com/',
'INTRANET_URL' => 'http://www.something.com',
'REMOVE_BUTTON' => "<INPUT TYPE=SUBMIT NAME=command VALUE=\"Remove Office\">",
'COMPANY_ADMIN_AREA' =>
"<A HREF=administrator.cgi?office_id=office_id&command=manage>Manage Office Administrators</A>",
'CASESTUDIES_LIST' =>
"adsfkljdskldszfgfdfdsgdsfgfdshghdmfldkgjfhdskjfhdskjhfkhdsakgagsfjhbvdsaj hsgbf jhfg sajfjdsag ffasfj hfkjhsdkjhdsakjfhkj kjhdsfkjhdskfjhdskjfkjsda kjjsafdkjhds kjds fkj skjh fdskjhfkj kj kjhf kjh sfkjhadsfkj hadskjfhkjhs ajhdsfkj akj fkj kj kj kkjdsfhk skjhadskfj haskjh fkjsahfkjhsfk ksjfhdkjh sfkjhdskjfhakj shiou weryheuwnjcinuc 3289u4234k 5 i 43iundsinfinafiunai saiufhiudsaf afiuhahfwefna uwhf u auiu uh weiuhfiuh iau huwehiucnaiuncianweciuninc iuaciun iucniunciunweiucniuwnciwe",
'NUMBER_OF_CONTACTS' => "aksfjdkldsajfkljds",
'COUNTRY_SELECTOR' => "klajslkjdsafkljds",
'LOGO_LINK' => "dsfpkjdsfkgljdsfkglj",
'PHOTO_LINK' => "lsadfjlkfjdsgkljhfgklhasgh",
}
],
long_loop => ['templates/long_loops.tmpl', {}],
loop_if => ['templates/loop-if.tmpl', {LOOP_ONE => [{VAR => 'foo'}]}]
);
# a hash of option hashes to test
my %options = (
'no cache' => {},
#'simple cache' => { cache => 1 },
# 'shared cache' => { shared_cache => 1, cache => 1 },
'file cache' => {
file_cache => 1,
file_cache_dir => './file_cache'
},
# 'simple cache, no_includes' => { cache => 1, no_includes => 1},
# 'blind cache' => { blind_cache => 1},
);
# number of times over each template
my $n = 100;
#open(OUT, ">test.out");
foreach my $template (keys %templates) {
print "\nTESTING : $template : $n iterations\n\n";
foreach my $option (keys %options) {
my $start_time = (times)[0];
for (my $x = 0 ; $x < $n ; $x++) {
my $template = HTML::Template->new(
filename => $templates{$template}->[0],
%{$options{$option}}
);
foreach my $name (keys %{$templates{$template}->[1]}) {
$template->param($name => $templates{$template}->[1]->{$name});
}
my $result = $template->output;
#print OUT $result;
#$template->output(print_to => *OUT);
}
my $end_time = (times)[0];
print "$option : average iteration in " . (($end_time - $start_time) / $n) . " seconds\n";
}
}