>>>>> "Stas" == Stas Bekman <[EMAIL PROTECTED]> writes:
    Stas> Is this a question or a suggestion? but in both cases
    Stas> (mod_perl and perl benchmark) the process doesn't exit, so
    Stas> the allocated datastructure is reused... anyway it should be
    Stas> the same. But it's not.

It was a suggestion.  Examining the optrees produced by aggrlist_print
and the following two routines which should be equivalent to
concat_print and multi_print from your original posting

   sub concat_print{
      my $buffer;
      $buffer .= "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n";
      $buffer .= "<HTML>\n";
      $buffer .= "  <HEAD>\n";
      $buffer .= "</HTML>\n";
      print $buffer;
   }

   sub aggrlist_print{
      my @buffer = ();
      push @buffer,"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n";
      push @buffer,"<HTML>\n";
      push @buffer,"  <HEAD>\n";
      push @buffer,"</HTML>\n";
      print @buffer;
   }

   sub multi_print{
      print "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">\n";
      print "<HTML>\n";
      print "  <HEAD>\n";
      print "</HTML>\n";
   }

shows that aggrlist_print performs 25% OPs than concat_list and 43%
more OPs than multi_print.

    Stas> handler:
    Stas> concat_print    |    111      5000      0    876 
    Stas> aggrlist_print  |    113      5000      0    862 
    Stas> multi_print     |    118      5000      0    820 

    Stas> buffered benchmark:

    Stas> concat_print:    8 wallclock secs ( 8.23 usr +  0.05 sys =  8.28 CPU)
    Stas> multi_print:    10 wallclock secs (10.70 usr +  0.01 sys = 10.71 CPU)
    Stas> aggrlist_print: 30 wallclock secs (31.06 usr +  0.04 sys = 31.10 CPU)

    Stas> Watch the aggrlist_print gives such a bad perl benchmark,
    Stas> but very good handler benchmark...

As Matt has already commented, in the handler the method call
overheads swamps all the other activities. so concat_print &
aggrlist_print (yes, method invocation in perl really is that bad).
When you remove that overhead the extra OPs in aggrlist_print become
the dominating factor.

-- 
Stephen

"So if she weighs the same as a duck, she's made of wood."... "And
therefore?"... "A witch!"

Reply via email to