我不想进入解释讨论(对于大多数现实世界的场景,这些开销根本没有影响) - 但这是我的测试:
1.纯普莱克
zby@zby:~/progs/bench$ cat app.psgi
sub {
my ( $env ) = @_;
return [
200,
[ 'Content-Type' => 'text/text' ],
[ 'Hello World' ]
];
}
zby@zby:~/progs/bench$ plackup
HTTP::Server::PSGI: Accepting connections at http://0:5000/
简单ab -n 10000
我得到
每秒请求数:2168.05 [#/sec](平均)
2. 舞者
zby@zby:~/progs/bench$ cat dancer.pl
#!/usr/bin/perl
use Dancer;
get '/' => sub {
return "Why, hello there";
};
dance;
zby@zby:~/progs/bench$ perl dancer.pl
>> Dancer server 1950 listening on http://0.0.0.0:3000
== Entering the development dance floor ...
通过类似的 ab 测试,我得到
Requests per second: 1570.49 [#/sec] (mean)
3. Mojolicious::Lite
zby@zby:~/progs/bench$ cat mojo.pl
# Using Mojolicious::Lite will enable "strict" and "warnings"
use Mojolicious::Lite;
# Route with placeholder
get '/' => sub {
my $self = shift;
$self->render(text => "Hello!");
};
# Start the Mojolicious command system
app->start;
zby@zby:~/progs/bench$ perl mojo.pl daemon
Sat Jan 22 20:37:01 2011 info Mojo::Server::Daemon:320 [2315]: Server listening (http://*:3000)
Server available at http://*:3000.
结果:每秒请求数:763.72 [#/sec](平均值)
4. 催化剂。
不幸的是,代码太长了,无法在此处完整呈现,但 Root 控制器包含:
sub index :Path :Args(0) {
my ( $self, $c ) = @_;
# Hello World
$c->response->body( 'Hello World' );
}
结果是:
每秒请求数:727.93 [#/sec](平均值)
5.WebNano
zby@zby:~/progs/bench$ cat webnano.psgi
{
package MyApp;
use base 'WebNano';
1;
}
{
package MyApp::Controller;
use base 'WebNano::Controller';
sub index_action {
my $self = shift;
return 'This is my home';
}
1;
}
MyApp->new()->psgi_callback;
zby@zby:~/progs/bench$ plackup webnano.psgi
HTTP::Server::PSGI: Accepting connections at http://0:5000/
结果:
每秒请求数:1884.54 [#/sec](平均)
添加更多功能后,这将改变。