Created
April 3, 2013 15:35
-
-
Save kazeburo/5302308 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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