Stas Bekman <[EMAIL PROTECTED]> writes:

> Well, I've run the benchmark and it wasn't the case. Did it change 
> recently? Or do you think that the benchmark is not fair?
> 
> we are talking about this item
> http://perl.apache.org/guide/performance.html#Apache_args_vs_Apache_Request

Right- param() was rewritten as XS about 6-8 months ago; since then
I've benchmarked it a few times and found param() to be a bit faster than
args().  We'll be releasing a 1.0 version of libapreq as soon as Jim 
approves of the current CVS version.  Here's what I got using it on 
your benchmark (some differences: the tests were run against localhost 
running perl 5.00503 + mod_perl 1.26 + apache 1.3.22 and using Perl 
handlers instead of Apache::RegistryLoader scripts):

Stas's strings:
  my $query = [
                        join("&", map {"$_=".'e' x 10}  ('a'..'b')),
                        join("&", map {"$_=".'e' x 10}  ('a'..'z')),
              ];
Joe's strings:

  %Q = qw/ one alpha two beta three gamma four delta /;
  my $query = [ 
                        join("&", map "$_=$Q{$_}", keys %Q),
                        join("&", map "$_=".escape($_), %Q),
              ];

                 Stas's Query    Joe's Query
                 short   long   short   long

  table          124      91    119     112 
  args           125      93    116     110
  do             124     103    121     118

  param          132     106    128     123
  noparse        138     136    133     131
                    REQUESTS PER SECOND

Here I used ab with concurrency = 1 to avoid "complications",
but that shouldn't make a difference if we're talking subroutine
performance.  The real disappointment here is handler_table,
which would be the fastest if perl's tied hash implementation
didn't suck so badly.  IMO perl's performance for tied-variable
access is shameful, but apparently the problem is unfixable in
perl5.

HANDLERS:

    sub handler_args {
        my $r = shift;
        my %args = $r->args;

        $r->send_http_header('text/plain');
        print join "\n", %args;
    }

    sub handler_table {
        my $r = Apache::Request->new(shift);
        my %args = %{ $r->param };

        $r->send_http_header('text/plain');
        print join "\n", %$args;
    }

    sub handler_do {
        my $r = Apache::Request->new(shift);
        my args; $r->param->do( sub {$args{$_[0]}=$_[1];1} );

        $r->send_http_header('text/plain');
        print join "\n", %$args;
    }

    sub handler_param {
        my $r = Apache::Request->new(shift);
        my %args = map +( $_ => $r->param($_) ), $r->param;

        $r->send_http_header('text/plain');
        print join "\n", %args;
    }

    sub handler_noparse {
        my $r = shift;
        $r->send_http_header('text/plain');
        print "OK";
    }

-- 
Joe Schaefer

Reply via email to