Skip to content

Instantly share code, notes, and snippets.

@lestrrat
Created March 11, 2009 00:36
Show Gist options
  • Save lestrrat/77226 to your computer and use it in GitHub Desktop.
Save lestrrat/77226 to your computer and use it in GitHub Desktop.
use strict;
use lib "lib";
use Benchmark qw(cmpthese);
use Path::Router;
use Moose::Util::TypeConstraints;
my $router1 = Path::Router->new();
my $router2 = Path::Router->new(inline => 0);
foreach my $router (($router1, $router2)) {
$router->add_route("/blog");
$router->add_route("/blog/index");
$router->add_route("/blog/:x/?:y", defaults => { x => 1, y => 2 }, validations => { x => subtype('Int' => where { $_ < 30 }) });
}
my @paths = qw(
/blog/index
/blog/10/bar
/blog/20
);
cmpthese(10_000, {
original => sub {
$router2->match($_) for @paths;
},
regexp => sub {
($router1->match($_) or die "didn't match $_") for @paths;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment