miyagawa (owner)

Revisions

gist: 204513 Download_button fork
public
Public Clone URL: git://gist.github.com/204513.git
Embed All Files: show embed
lib/Plack/Middleware/NYTProf.pm #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package Plack::Middleware::NYTProf;
use strict;
use base qw(Plack::Middleware);
BEGIN { $ENV{NYTPROF} = "start=no" }
use Devel::NYTProf;
use Time::HiRes qw(gettimeofday);
 
sub call {
    my $self = shift;
 
    my $t = gettimeofday;
    my $nytprof = "nytprof.$t";
    DB::enable_profile($nytprof);
    my $res = $self->app->(@_);
    DB::finish_profile();
 
    system "nytprofhtml --file $nytprof --open" and warn $?;
 
    return $res;
}
 
1;