Skip to content

Instantly share code, notes, and snippets.

@kazeburo
Created April 3, 2013 15:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kazeburo/5302308 to your computer and use it in GitHub Desktop.
Save kazeburo/5302308 to your computer and use it in GitHub Desktop.
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