use strict; | |
use Benchmark qw/ :all /; | |
use File::Temp qw/ tempfile /; | |
use Storable qw/ nstore retrieve /; | |
use HTTP::Request::Common; | |
use HTTP::Message::PSGI; | |
use Plack::Builder; | |
use Plack::Test; | |
my $result = {}; | |
for my $name (qw/ extlib-1.0022 extlib-compiler /) { | |
my ($fh, $fn) = tempfile(); | |
my $pid = fork; | |
if ($pid) { | |
close $fh; | |
wait; | |
} | |
else { | |
eval qq{use lib '$name/lib/perl5'}; | |
my $log_app = builder { | |
enable 'AccessLog', format => "combined", logger => sub {}; | |
sub{ [ 200, [], [ "Hello"] ] }; | |
}; | |
my $env = req_to_psgi(GET "/"); | |
my $code = sub { | |
$log_app->($env); | |
}; | |
my $r = timethis(0, $code); | |
nstore $r, $fn; | |
exit; | |
} | |
$result->{$name} = retrieve $fn; | |
}; | |
cmpthese $result; | |
__END__ | |
$ cpanm -lextlib-1.0022 Plack | |
$ cpanm -lextlib-compiler git://github.com/kazeburo/Plack.git | |
$ perl -Mlib=extlib-1.0022/lib/perl5 benchmark.pl | |
timethis for 3: 3 wallclock secs ( 2.94 usr + 0.06 sys = 3.00 CPU) @ 6199.33/s (n=18598) | |
timethis for 3: 3 wallclock secs ( 3.17 usr + 0.00 sys = 3.17 CPU) @ 36421.77/s (n=115457) | |
Rate extlib-1.0022 extlib-compiler | |
extlib-1.0022 6199/s -- -83% | |
extlib-compiler 36422/s 488% -- | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment