line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::TimeStats; |
2
|
6
|
|
|
6
|
|
740057
|
use strict; |
|
6
|
|
|
|
|
43
|
|
|
6
|
|
|
|
|
179
|
|
3
|
6
|
|
|
6
|
|
40
|
use warnings; |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
186
|
|
4
|
6
|
|
|
6
|
|
512
|
use parent 'Plack::Middleware'; |
|
6
|
|
|
|
|
353
|
|
|
6
|
|
|
|
|
34
|
|
5
|
6
|
|
|
6
|
|
15933
|
use Plack::Util::Accessor qw/callback psgix option action/; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
50
|
|
6
|
6
|
|
|
6
|
|
3475
|
use Devel::TimeStats; |
|
6
|
|
|
|
|
608573
|
|
|
6
|
|
|
|
|
2048
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub prepare_app { |
11
|
7
|
|
|
7
|
1
|
19125
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
7
|
100
|
|
|
|
36
|
if ($self->psgix) { |
14
|
1
|
|
|
|
|
46
|
$self->psgix('psgix.'. $self->psgix); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
6
|
|
|
|
|
226
|
$self->psgix('psgix.timestats'); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
7
|
100
|
|
|
|
98
|
$self->option(+{ |
21
|
|
|
|
|
|
|
percentage_decimal_precision => 2, |
22
|
|
|
|
|
|
|
}) unless $self->option; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->callback( |
25
|
|
|
|
|
|
|
sub { |
26
|
5
|
|
|
5
|
|
71
|
my ($stats, $env, $res) = @_; |
27
|
5
|
|
|
|
|
146
|
warn scalar($stats->report); |
28
|
|
|
|
|
|
|
} |
29
|
7
|
100
|
|
|
|
114
|
) unless $self->callback; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub call { |
33
|
7
|
|
|
7
|
1
|
108602
|
my($self, $env) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
39
|
$env->{$self->psgix} = Devel::TimeStats->new($self->option); |
36
|
|
|
|
|
|
|
|
37
|
7
|
100
|
|
|
|
12873
|
my $action = $self->action ? $self->action->($env) : $env->{PATH_INFO}; |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
79
|
$env->{$self->psgix}->profile( |
40
|
|
|
|
|
|
|
begin => $action, |
41
|
|
|
|
|
|
|
comment => '', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
2026
|
my $res = $self->app->($env); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->response_cb($res, sub { |
47
|
7
|
|
|
7
|
|
316
|
my $res = shift; |
48
|
|
|
|
|
|
|
|
49
|
7
|
|
|
|
|
65
|
$env->{$self->psgix}->profile( |
50
|
|
|
|
|
|
|
end => $action, |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
|
53
|
7
|
|
|
|
|
1306
|
$self->callback->($env->{$self->psgix}, $env, $res); |
54
|
7
|
|
|
|
|
97177
|
return; |
55
|
7
|
|
|
|
|
7003586
|
}); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |