Skip to content

Commit

Permalink
use test_tcp directly to do better cleanup for ServerSimple (i guess)
Browse files Browse the repository at this point in the history
  • Loading branch information
miyagawa committed Oct 4, 2009
1 parent 9f69577 commit 628b810
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions benchmarks/ab.pl
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ sub main {

sub run_one {
my $server_class = shift;
my $port = Test::TCP::empty_port();
print "-- server: $server_class\n";

my $pid = fork();
if ($pid > 0) { # parent
Test::TCP::wait_port($port);
my $uri = URI->new($url);
$uri->port($port);
$uri = shell_quote($uri);
print `$ab $uri | grep 'Requests per '`;
kill 'TERM' => $pid;
wait();
} else {
my $handler = Plack::Util::load_psgi $app;
my $server = Plack::Loader->load($server_class, port => $port);
$server->run($handler);
}
test_tcp(
client => sub {
my $port = shift;
my $uri = URI->new($url);
$uri->port($port);
$uri = shell_quote($uri);
print `$ab $uri | grep 'Requests per '`;
},
server => sub {
my $port = shift;
my $handler = Plack::Util::load_psgi $app;
my $server = Plack::Loader->load($server_class, port => $port);
$server->run($handler);
},
);
}


0 comments on commit 628b810

Please sign in to comment.