Created
September 27, 2009 07:54
-
-
Save sharifulin/194660 to your computer and use it in GitHub Desktop.
Simple Mojo server
This file contains hidden or 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 FindBin; | |
use lib "$FindBin::Bin/../lib"; | |
use lib "$FindBin::Bin/../../lib"; | |
# Application | |
$ENV{MOJO_APP} ||= 'Bench'; | |
use Mojo::Commands; | |
Mojo::Commands->start('daemon', '--port' => 8010); | |
package Bench; | |
use strict; | |
use warnings; | |
use base 'Mojo'; | |
sub handler { | |
my ($self, $tx) = @_; | |
for($tx->res) { | |
$_->headers->content_type('text/plain'); | |
$_->body($tx->req->param('a') + $tx->req->param('b')); | |
} | |
} | |
1; | |
__END__ | |
ab -n 1000 'http://127.0.0.1:8010/?a=3&b=5' | |
Requests per second: 254.49 [#/sec] (mean) | |
ab -n 1000 -c 100 'http://127.0.0.1:8010/?a=3&b=5' | |
Requests per second: 260.79 [#/sec] (mean) | |
ab -n 1000 -c 10 'http://127.0.0.1:8010/?a=3&b=5' | |
Requests per second: 275.03 [#/sec] (mean) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment