Christopher P. Lindsey wrote:
[...]
It looks like the problem is repeated print statements.  I basically
had a loop that did

   while ($ref = $sth->fetchrow_arrayref()) {
      print $$ref[0], $$ref[2], etc.
   }

Changing it to

   my $output;
   while ($ref = $sth->fetchrow_arrayref()) {
      $output .= $$ref[0] . $$ref[2], etc.
   }
   print $output;

cut the load time to 1.03 seconds -- that's 1/3 of the timing with multiple
print statements and 2/3 of the timing for the CGI script.

So the lesson I learned is to store all of your output when using Apache::Filter, then print it all out at once.

Thanks for the pointer, Perrin!

You can probably further optimize it using an array instead of concatenation. But benchmark it first to see whether it does make things faster. See:
http://perl.apache.org/docs/1.0/guide/performance.html#Interpolation__Concatenation_or_List


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- Reporting bugs: http://perl.apache.org/bugs/ Mail list info: http://perl.apache.org/maillist/modperl.html



Reply via email to