ServerTiming.pm

filter: Statementstmt 100% 24 / 24 Branchbran n/a Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 8 / 8 Podpod 100% 3 / 3 totaltotal 100% 38 / 38 CC 2 SCAR 2.0
CC
2
Cov
100%
record_timing
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Middleware/ServerTiming.pm ↑ Summary
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 ||= {}
l!l
31
MC/DC100%1/1
$field ||= {}
$field
Truth table100%2/2
A
A= $field
Aresult
11
00
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__
« Middleware/ServerTiming.pm ↑ Summary