line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::TimeStats; |
2
|
6
|
|
|
6
|
|
796945
|
use strict; |
|
6
|
|
|
|
|
97
|
|
|
6
|
|
|
|
|
196
|
|
3
|
6
|
|
|
6
|
|
36
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
218
|
|
4
|
6
|
|
|
6
|
|
544
|
use parent 'Plack::Middleware'; |
|
6
|
|
|
|
|
371
|
|
|
6
|
|
|
|
|
53
|
|
5
|
6
|
|
|
6
|
|
16746
|
use Plack::Util::Accessor qw/callback psgix option action/; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
52
|
|
6
|
6
|
|
|
6
|
|
3555
|
use Devel::TimeStats; |
|
6
|
|
|
|
|
624585
|
|
|
6
|
|
|
|
|
2156
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.05'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub prepare_app { |
11
|
7
|
|
|
7
|
1
|
20679
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
7
|
100
|
|
|
|
50
|
if ($self->psgix) { |
14
|
1
|
|
|
|
|
38
|
$self->psgix('psgix.'. $self->psgix); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
6
|
|
|
|
|
226
|
$self->psgix('psgix.timestats'); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
7
|
100
|
|
|
|
105
|
$self->option(+{ |
21
|
|
|
|
|
|
|
percentage_decimal_precision => 2, |
22
|
|
|
|
|
|
|
}) unless $self->option; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->callback( |
25
|
|
|
|
|
|
|
sub { |
26
|
5
|
|
|
5
|
|
66
|
my ($stats, $env, $res) = @_; |
27
|
5
|
|
|
|
|
36
|
warn scalar($stats->report); |
28
|
|
|
|
|
|
|
} |
29
|
7
|
100
|
|
|
|
126
|
) unless $self->callback; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub call { |
33
|
7
|
|
|
7
|
1
|
109348
|
my($self, $env) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
55
|
$env->{$self->psgix} = Devel::TimeStats->new($self->option); |
36
|
|
|
|
|
|
|
|
37
|
7
|
100
|
|
|
|
13337
|
my $action = $self->action ? $self->action->($env) : $env->{PATH_INFO}; |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
103
|
$env->{$self->psgix}->profile( |
40
|
|
|
|
|
|
|
begin => $action, |
41
|
|
|
|
|
|
|
comment => '', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
2318
|
my $res = $self->app->($env); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->response_cb($res, sub { |
47
|
7
|
|
|
7
|
|
263
|
my $res = shift; |
48
|
|
|
|
|
|
|
|
49
|
7
|
|
|
|
|
63
|
$env->{$self->psgix}->profile( |
50
|
|
|
|
|
|
|
end => $action, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
7
|
|
|
|
|
1165
|
$self->callback->($env->{$self->psgix}, $env, $res); |
54
|
7
|
|
|
|
|
30995
|
return; |
55
|
7
|
|
|
|
|
7003402
|
}); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |