> > I don't understand what you're getting at. Does this mean that something
> > shouldn't be optimized because there's something else in the process that
> > is taking more time? For example I have a database powered site, the slowest
> > part of request processing is fetching data from the database. Should I
> > disregard any optimization not dealing with the database fetches ? These
> > things add up, so don't you think that whatever can be optimized, should ?
> > Of course the slowest stuff should be optimized first, but that doesn't
> > mean that other optimisations are useless.
>
> Of course you can optimize forever, but some optimizations aren't going to
> make a whole lot of difference. This is one of those optimizations,
> judging by these benchmarks. Let Stas re-write this benchmark test as a
> handler() and see what kind of difference it makes. I'm willing to
> bet: barely any between averages.
>
> Perhaps I was a little strong: Lets not deprecate this part of the guide,
> just provide some realism in the conclusion.
here we go, the benchmark holds for all but list_print!!!
query | avtime completed failed rps
-----------------------------------------------
here_print | 109 5000 0 894
single_print | 110 5000 0 883
list_print | 111 5000 0 877
multi_print | 118 5000 0 817
-----------------------------------------------
Here is the module used in benchmarking:
package MyPrint;
use Apache::Constants qw(:common);
use Apache::URI ();
my %callbacks = (
list_print => \&list_print,
multi_print => \&multi_print,
single_print => \&single_print,
here_print => \&here_print,
);
sub handler{
my $r = shift;
$r->send_http_header('text/plain');
my $uri = Apache::URI->parse($r);
my $query = $uri->query;
return DECLINED unless $callbacks{$query};
&{$callbacks{$query}};
return OK;
}
sub multi_print{
print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n";
print "<HTML>\n";
print " <HEAD>\n";
print " <TITLE>\n";
print " Test page\n";
print " </TITLE>\n";
print " </HEAD>\n";
print " <BODY BGCOLOR=\"black\" TEXT=\"white\">\n";
print " <H1> \n";
print " Test page \n";
print " </H1>\n";
print " <A HREF=\"foo.html\">foo</A>\n";
print " <HR>\n";
print " </BODY>\n";
print "</HTML>\n";
}
sub single_print{
print qq{<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<TITLE>
Test page
</TITLE>
</HEAD>
<BODY BGCOLOR="black" TEXT="white">
<H1>
Test page
</H1>
<A HREF="foo.html">foo</A>
<HR>
</BODY>
</HTML>
};
}
sub here_print{
print <<__EOT__;
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<HTML>
<HEAD>
<TITLE>
Test page
</TITLE>
</HEAD>
<BODY BGCOLOR="black" TEXT="white">
<H1>
Test page
</H1>
<A HREF="foo.html">foo</A>
<HR>
</BODY>
</HTML>
__EOT__
}
sub list_print{
print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n",
"<HTML>\n",
" <HEAD>\n",
" <TITLE>\n",
" Test page\n",
" </TITLE>\n",
" </HEAD>\n",
" <BODY BGCOLOR=\"black\" TEXT=\"white\">\n",
" <H1> \n",
" Test page \n",
" </H1>\n",
" <A HREF=\"foo.html\">foo</A>\n",
" <HR>\n",
" </BODY>\n",
"</HTML>\n";
}
1;
_____________________________________________________________________
Stas Bekman JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide http://perl.apache.org/guide
mailto:[EMAIL PROTECTED] http://perl.org http://stason.org/TULARC
http://singlesheaven.com http://perlmonth.com http://sourcegarden.org