Last active
December 22, 2015 15:19
-
-
Save ytnobody/6492083 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
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
use lib qw(BitterMilk/lib SugarMilk/lib HornyMilk/lib); | |
use Benchmark qw(:all); | |
use BitterMilk; | |
use SugarMilk; | |
use HornyMilk::Web; | |
use Data::Dumper; | |
sub mock_env { | |
+{ | |
'SERVER_NAME' => 'localhost', | |
'SCRIPT_NAME' => '', | |
'PATH_INFO' => '/', | |
'CONTENT_LENGTH' => 0, | |
'REQUEST_METHOD' => 'GET', | |
'REMOTE_PORT' => 19783, | |
'QUERY_STRING' => 'name=ytnobody', | |
'SERVER_PORT' => 80, | |
'REMOTE_ADDR' => '127.0.0.1', | |
'SERVER_PROTOCOL' => 'HTTP/1.1', | |
'REQUEST_URI' => '/?name=ytnobody', | |
'REMOTE_HOST' => 'localhost', | |
'HTTP_HOST' => 'localhost', | |
}; | |
} | |
my $bm = BitterMilk->run; | |
my $sm = SugarMilk->run; | |
my $hm = HornyMilk::Web->to_app; | |
my $milk = sub { [200, [], ['Hello, World!']] }; | |
my $incr = { nephia_simple => 0, nephia_normal => 0, amon2 => 0, vanilla => 0 }; | |
my $count = 100000; | |
my $env = mock_env(); | |
cmpthese($count, { | |
nephia_simple => sub { | |
my $res = $bm->($env); | |
$incr->{nephia_simple}++ if ref($res) eq 'ARRAY'; | |
}, | |
nephia_normal => sub { | |
my $res = $hm->($env); | |
$incr->{nephia_normal}++ if ref($res) eq 'ARRAY'; | |
}, | |
amon2 => sub { | |
my $res = $hm->($env); | |
$incr->{amon2}++ if ref($res) eq 'ARRAY'; | |
}, | |
vanilla_psgi => sub { | |
my $res = $milk->($env); | |
$incr->{vanilla}++ if ref($res) eq 'ARRAY'; | |
}, | |
}); | |
print Dumper($incr); |
Author
ytnobody
commented
Sep 9, 2013
Rate nephia_normal amon2 nephia_simple vanilla_psgi
nephia_normal 2170/s -- -1% -81% -100%
amon2 2190/s 1% -- -81% -100%
nephia_simple 11655/s 437% 432% -- -99%
vanilla_psgi 1111111/s 51100% 50644% 9433% --
$VAR1 = {
'nephia_normal' => 100000,
'vanilla' => 100000,
'nephia_simple' => 100000,
'amon2' => 100000
};
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment