line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::ServerTiming; |
2
|
3
|
|
|
3
|
|
228416
|
use strict; |
|
3
|
|
|
|
|
26
|
|
|
3
|
|
|
|
|
88
|
|
3
|
3
|
|
|
3
|
|
15
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
458
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
sub new { |
6
|
2
|
|
|
2
|
1
|
98
|
my ($class, $env) = @_; |
7
|
2
|
|
|
|
|
9
|
return bless { |
8
|
|
|
|
|
|
|
env => $env, |
9
|
|
|
|
|
|
|
} => $class; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub record_timing { |
13
|
4
|
|
|
4
|
1
|
19
|
my ($self, $name, $field) = @_; |
14
|
4
|
|
100
|
|
|
13
|
$field ||= {}; |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
5
|
push @{ $self->{env}->{'psgix.server-timing'} } => [$name, $field]; |
|
4
|
|
|
|
|
13
|
|
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub guard { |
20
|
1
|
|
|
1
|
1
|
7
|
my $self = shift; |
21
|
1
|
|
|
|
|
8
|
return Plack::ServerTiming::Guard->new($self->{env}, @_); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
package # hide from pause |
25
|
|
|
|
|
|
|
Plack::ServerTiming::Guard; |
26
|
3
|
|
|
3
|
|
1408
|
use Time::HiRes; |
|
3
|
|
|
|
|
3603
|
|
|
3
|
|
|
|
|
12
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub new { |
29
|
1
|
|
|
1
|
|
5
|
my ($class, $env, $name, $desc) = @_; |
30
|
1
|
|
|
|
|
19
|
return bless { |
31
|
|
|
|
|
|
|
env => $env, |
32
|
|
|
|
|
|
|
start => [Time::HiRes::gettimeofday], |
33
|
|
|
|
|
|
|
name => $name, |
34
|
|
|
|
|
|
|
desc => $desc, |
35
|
|
|
|
|
|
|
}, $class; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub DESTROY { |
39
|
1
|
|
|
1
|
|
1000255
|
my $self = shift; |
40
|
1
|
|
|
|
|
29
|
my $dur = Time::HiRes::tv_interval($self->{start}) * 1000; |
41
|
1
|
|
|
|
|
53
|
push @{ $self->{env}->{'psgix.server-timing'} } => [$self->{name}, {dur => $dur, desc => $self->{desc}}]; |
|
1
|
|
|
|
|
20
|
|
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
__END__ |