Permalink
Browse files

Add benchmarking Plack middleware

  • Loading branch information...
1 parent 654e489 commit 4d45603ca565f6390b2935519d7303d38c76d266 @ctfliblime ctfliblime committed Jul 2, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 Koha/Plack/Benchmark.pm
View
@@ -0,0 +1,17 @@
+package Koha::Plack::Benchmark;
+use parent qw(Plack::Middleware);
+
+use Koha;
+use Time::HiRes qw(gettimeofday tv_interval);
+
+sub call {
+ my ($self, $env) = @_;
+ my $t0 = [gettimeofday];
+ my $res = $self->app->($env);
+ my $elapsed = tv_interval ( $t0 );
+ printf STDERR "BENCHMARK:%.05f:%s\n", $elapsed, $env->{REQUEST_URI};
+
+ return $res;
+}
+
+1;

0 comments on commit 4d45603

Please sign in to comment.