Skip to content

Instantly share code, notes, and snippets.

@ytnobody
Last active December 23, 2015 15:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ytnobody/6657962 to your computer and use it in GitHub Desktop.
Save ytnobody/6657962 to your computer and use it in GitHub Desktop.
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

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