You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Stas Bekman <sb...@stason.org> on 2000/04/14 19:35:41 UTC
[RFC] Benchmarking CGI.pm and Apache::Request
=head1 Benchmarking CGI.pm and Apache::Request
Let's write two registry scripts that use C<CGI.pm> and
C<Apache::Request> to process the form's input and print it out.
benchmarks/cgi_pm.pl
--------------------
use strict;
use CGI;
my $q = new CGI;
print $q->header('text/plain');
print join "\n", map {"$_ => ".$q->param($_) } $q->param;
benchmarks/apache_request.pl
----------------------------
use strict;
use Apache::Request ();
my $r = Apache->request;
my $q = Apache::Request->new($r);
$r->send_http_header('text/plain');
print join "\n", map {"$_ => ".$q->param($_) } $q->param;
Now let's benchmark the two:
% ab -n 1000 -c 10 \
'http://localhost/perl/benchmarks/cgi_pm.pl?a=b&c=+k+d+d+f&d=asf&as=+1+2+3+4'
Time taken for tests: 57.112 seconds
Requests per second: 17.51
Connnection Times (ms)
min avg max
Connect: 0 6 319
Processing: 191 561 4563
Total: 191 567 4882
% ab -n 1000 -c 10 \
'http://localhost/perl/benchmarks/apache_request.pl?a=b&c=+k+d+d+f&d=asf&as=+1+2+3+4'
Time taken for tests: 23.662 seconds
Requests per second: 42.26
Connnection Times (ms)
min avg max
Connect: 0 3 263
Processing: 152 232 597
Total: 152 235 860
Apparently the latter script using C<Apache::Request> is more than
twice and a half faster.
Again this benchmark shows that the real timing of the input
processing, when the script is much heavier the overhead of using
C<CGI.pm> can be insignificant.
______________________________________________________________________
Stas Bekman | JAm_pH -- Just Another mod_perl Hacker
http://stason.org/ | mod_perl Guide http://perl.apache.org/guide
mailto:stas@stason.org | http://perl.org http://stason.org/TULARC/
http://singlesheaven.com| http://perlmonth.com http://sourcegarden.org
----------------------------------------------------------------------