Skip to content

Commit

Permalink
Tidy up source code
Browse files Browse the repository at this point in the history
This commit will show up in git blame a lot.
  • Loading branch information
bbrtj committed Jun 20, 2024
1 parent 3f9c209 commit 9bd7d89
Show file tree
Hide file tree
Showing 84 changed files with 2,206 additions and 1,879 deletions.
25 changes: 15 additions & 10 deletions ex/router_bench.pl
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,27 @@
my $path = join '', map { "/$_" } 1 .. $depth, 'handler';

{

package TestApp;

use Kelp::Base 'Kelp';

sub hello { 'hello' }
sub hi { 'hi' }
sub hi { 'hi' }
}

my $app = TestApp->new;

sub prepare_match {
sub prepare_match
{
my $r = shift;
return sub { $r->match($path) };
}

sub prepare_dispatch {
sub prepare_dispatch
{
my $r = shift;
my @routes = @{ $r->match($path) };
my @routes = @{$r->match($path)};

return sub { $r->dispatch($app, $_) for @routes };
}
Expand Down Expand Up @@ -52,17 +55,19 @@ sub prepare_dispatch {
'/handler' => 'hello',
);

$r->add('' => {
to => sub { 1 },
tree => $tree_base,
});
$r->add(
'' => {
to => sub { 1 },
tree => $tree_base,
}
);

say "$class matches: " . join ', ', map { '"' . $_->name . '"' } @{ $r->match($path) };
say "$class matches: " . join ', ', map { '"' . $_->name . '"' } @{$r->match($path)};
$cases{"$class->match"} = prepare_match($r);
$cases{"$class->dispatch"} = prepare_dispatch($r);
}

cmpthese -2, \%cases;
cmpthese - 2, \%cases;

# benchmarks different implementations of Kelp::Routes
# usage: ex/router_bench.pl [<depth> <classname1> <classname2> ...]
Expand Down
Loading

0 comments on commit 9bd7d89

Please sign in to comment.