line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::TimeStats; |
2
|
6
|
|
|
6
|
|
310605
|
use strict; |
|
6
|
|
|
|
|
7
|
|
|
6
|
|
|
|
|
140
|
|
3
|
6
|
|
|
6
|
|
19
|
use warnings; |
|
6
|
|
|
|
|
6
|
|
|
6
|
|
|
|
|
128
|
|
4
|
6
|
|
|
6
|
|
682
|
use parent 'Plack::Middleware'; |
|
6
|
|
|
|
|
242
|
|
|
6
|
|
|
|
|
29
|
|
5
|
6
|
|
|
6
|
|
10808
|
use Plack::Util::Accessor qw/callback psgix option action/; |
|
6
|
|
|
|
|
5
|
|
|
6
|
|
|
|
|
30
|
|
6
|
6
|
|
|
6
|
|
2755
|
use Devel::TimeStats; |
|
6
|
|
|
|
|
430470
|
|
|
6
|
|
|
|
|
1649
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub prepare_app { |
11
|
7
|
|
|
7
|
1
|
11761
|
my $self = shift; |
12
|
|
|
|
|
|
|
|
13
|
7
|
100
|
|
|
|
26
|
if ($self->psgix) { |
14
|
1
|
|
|
|
|
33
|
$self->psgix('psgix.'. $self->psgix); |
15
|
|
|
|
|
|
|
} |
16
|
|
|
|
|
|
|
else { |
17
|
6
|
|
|
|
|
147
|
$self->psgix('psgix.timestats'); |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
7
|
100
|
|
|
|
51
|
$self->option(+{ |
21
|
|
|
|
|
|
|
percentage_decimal_precision => 2, |
22
|
|
|
|
|
|
|
}) unless $self->option; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
$self->callback( |
25
|
|
|
|
|
|
|
sub { |
26
|
5
|
|
|
5
|
|
53
|
my ($stats, $env, $res) = @_; |
27
|
5
|
|
|
|
|
45
|
warn scalar($stats->report); |
28
|
|
|
|
|
|
|
} |
29
|
7
|
100
|
|
|
|
75
|
) unless $self->callback; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub call { |
33
|
7
|
|
|
7
|
1
|
73568
|
my($self, $env) = @_; |
34
|
|
|
|
|
|
|
|
35
|
7
|
|
|
|
|
30
|
$env->{$self->psgix} = Devel::TimeStats->new($self->option); |
36
|
|
|
|
|
|
|
|
37
|
7
|
100
|
|
|
|
8411
|
my $action = $self->action ? $self->action->($env) : $env->{PATH_INFO}; |
38
|
|
|
|
|
|
|
|
39
|
7
|
|
|
|
|
69
|
$env->{$self->psgix}->profile( |
40
|
|
|
|
|
|
|
begin => $action, |
41
|
|
|
|
|
|
|
comment => '', |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
7
|
|
|
|
|
3093
|
my $res = $self->app->($env); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
$self->response_cb($res, sub { |
47
|
7
|
|
|
7
|
|
123
|
my $res = shift; |
48
|
|
|
|
|
|
|
|
49
|
7
|
|
|
|
|
27
|
$env->{$self->psgix}->profile('end app'); |
50
|
|
|
|
|
|
|
|
51
|
7
|
|
|
|
|
1082
|
$env->{$self->psgix}->profile( |
52
|
|
|
|
|
|
|
end => $action, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
7
|
|
|
|
|
428
|
$self->callback->($env->{$self->psgix}, $env, $res); |
56
|
7
|
|
|
|
|
26349
|
return; |
57
|
7
|
|
|
|
|
1001773
|
}); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |