Hi Matthew,
Are you using 'global_vars', then H::T can be made to have a very
large speed up by replacing the code from lines 2624-2650 with:
if (scalar(@{$options->{associate}})) {
my @undef_params;
foreach my $param (keys %{$self->{param_map}}) {
next if (defined $self->param($param));
push @undef_params, $param;
}
if (scalar(@undef_params)) {
my $value;
# if case sensitive mode or no CGI objects, we can use the
fast path
if ($options->{case_sensitive} or (grep { !/^1/ } map {
UNIVERSAL::isa($_,'HTML::Template') } @{$options->{associate}}) == 0) {
foreach my $param (@undef_params) {
foreach my $associated_object (reverse
@{$options->{associate}}) {
$value = $associated_object->param($param);
next unless (defined $value);
$self->param($param, scalar $value);
last;
}
}
} else {
my %case_map;
foreach my $associated_object (@{$options->{associate}}) {
map { $case_map{$associated_object}{lc($_)} = $_ }
$associated_object->param();
}
my $associated_param;
foreach my $param (@undef_params) {
foreach my $associated_object (reverse
@{$options->{associate}}) {
$associated_param = $case_map{$associated_object}{$param};
next unless (defined $associated_param);
$value = $associated_object->param($associated_param);
next unless (defined $value);
$self->param($param, scalar $value);
last;
}
}
}
}
}
Basically, the existing code is "loop intensive" - the replacement
code the big loops with smaller loops, thus the code runs faster.
In our app, this change resulted a 10x speedup in some specific cases.
Matthew wrote:
> Hey guys,
>
> Over the weekend, we (finally!) moved our company's primary web-app
> from CGI over to mod_perl and incorporated H::T. The funny thing is
> that I started doing some speed comparisons using ApacheBench of our MP
> version vs CGI.
>
> Short story is, both CGI and MP preformed about the same. In some
> cases CGI was actually faster than MP. This bummed me out. I used
> Apache::DProf to get an idea of what calls where taking the longest.
>
> Turns out that H::T takes at least 25% of the processing time each
> time a MP request is made. Our CGI was using some in-house "template"
> system. (ie: file open, search/replace line by line for variables, print
> out).
>
> Like I said, this really bummed me out. For the longest time, CGI
> was WAY faster than MP, until I turned on cache => 1 in H:T. That was a
> HUGE improvement, but still CGI is slightly faster.
>
> I've already got "use HTML::Template" in my startup.pl so
> theoretically its being compiled at server start (anyway to verify
> this?). But its the instantiation in my handler() routine that's using
> the CPU time.
>
> How I can I get H:T to preform better?
>
> Thanks,
> Matthew
>
> Using Tomcat but need to do more? Need to support web services, security?
> Get stuff done quickly with pre-integrated technology to make your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
> _______________________________________________
> Html-template-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/html-template-users
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Html-template-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/html-template-users