Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Last active Dec 23, 2015
Embed
What would you like to do?
use strict;
use Benchmark qw(:all);
use Router::Simple;
use Dispatcher::Small;
use Data::Dumper;
my $rs = Router::Simple->new;
$rs->connect('/user/:id' => {action => 'user'});
my $ds = Dispatcher::Small->new(
qr'^/user/(?<id>.+)' => {action => 'user'},
);
my $path = '/user/oreore';
warn Dumper({
RouterSimple => $rs->match($path),
DispatcherSmall => $ds->match($path),
});
cmpthese( 100000, {
Router_Simple => sub { $rs->match($path) },
Dispatcher_Small => sub { $ds->match($path) },
}) for 1 .. 3;
@ytnobody
Copy link
Author

ytnobody commented Sep 24, 2013

tuned.

$VAR1 = {
          'DispatcherSmall' => {
                                 'action' => 'user',
                                 'id' => 'oreore'
                               },
          'RouterSimple' => {
                              'action' => 'user',
                              'id' => 'oreore'
                            }
        };
                     Rate    Router_Simple Dispatcher_Small
Router_Simple    121951/s               --             -10%
Dispatcher_Small 135135/s              11%               --
                     Rate    Router_Simple Dispatcher_Small
Router_Simple    120482/s               --             -12%
Dispatcher_Small 136986/s              14%               --
                     Rate    Router_Simple Dispatcher_Small
Router_Simple    120482/s               --             -12%
Dispatcher_Small 136986/s              14%               --

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment