| 1 | package Plack::ServerTiming; | ||||||||||||
| 2 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 3 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | |||||||||||||
| 5 | 2 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 6 | 2 | my ($class, $env) = @_; | |||||||||||
| 7 | 2 | return bless { | |||||||||||
| 8 | env => $env, | ||||||||||||
| 9 | } => $class; | ||||||||||||
| 10 | } | ||||||||||||
| 11 | |||||||||||||
| 12 | 4 | ▶ | sub record_timing { | ||||||||||
|
Subroutine
record_timing: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||
| 13 | 4 | my ($self, $name, $field) = @_; | |||||||||||
| 14 | 4 | ▶ | $field ||= {}; | ||||||||||
|
Condition100%2/2
$field ||= {}
MC/DC100%1/1
$field ||= {}
$field
Truth table100%2/2
A
A= $field
| |||||||||||||
| 15 | |||||||||||||
| 16 | 4 | push @{ $self->{env}->{'psgix.server-timing'} } => [$name, $field]; | |||||||||||
| 17 | } | ||||||||||||
| 18 | |||||||||||||
| 19 | 1 | ▶ | sub guard { | ||||||||||
|
Subroutine
guard: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 20 | 1 | my $self = shift; | |||||||||||
| 21 | 1 | return Plack::ServerTiming::Guard->new($self->{env}, @_); | |||||||||||
| 22 | } | ||||||||||||
| 23 | |||||||||||||
| 24 | package # hide from pause | ||||||||||||
| 25 | Plack::ServerTiming::Guard; | ||||||||||||
| 26 | 3 | ▶ | use Time::HiRes; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 27 | |||||||||||||
| 28 | 1 | ▶ | sub new { | ||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||
| 29 | 1 | my ($class, $env, $name, $desc) = @_; | |||||||||||
| 30 | 1 | return bless { | |||||||||||
| 31 | env => $env, | ||||||||||||
| 32 | start => [Time::HiRes::gettimeofday], | ||||||||||||
| 33 | name => $name, | ||||||||||||
| 34 | desc => $desc, | ||||||||||||
| 35 | }, $class; | ||||||||||||
| 36 | } | ||||||||||||
| 37 | |||||||||||||
| 38 | 1 | ▶ | sub DESTROY { | ||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||
| 39 | 1 | my $self = shift; | |||||||||||
| 40 | 1 | my $dur = Time::HiRes::tv_interval($self->{start}) * 1000; | |||||||||||
| 41 | 1 | push @{ $self->{env}->{'psgix.server-timing'} } => [$self->{name}, {dur => $dur, desc => $self->{desc}}]; | |||||||||||
| 42 | } | ||||||||||||
| 43 | |||||||||||||
| 44 | 3 | 1; | |||||||||||
| 45 | __END__ | ||||||||||||