Created
March 11, 2009 00:36
-
-
Save lestrrat/77226 to your computer and use it in GitHub Desktop.
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
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