Reply/Plugin/Timer.pm

filter: Statementstmt 51.7% 15 / 29 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 66.6% 4 / 6 Podpod 50.0% 1 / 2 totaltotal 45.4% 20 / 44 CC 4 SCAR 17.5
CC
4
Cov
43%
execute
12.0
new
6.0
BEGIN
1.0
CRAP 5.8
« Reply/Plugin/ResultCache.pm ↑ Summary Reply/Plugin/Nopaste.pm »
1 package Reply::Plugin::Timer;
2 1 our $AUTHORITY = 'cpan:DOY';
3 1 $Reply::Plugin::Timer::VERSION = '0.42';
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 # ABSTRACT: time commands
7  
8 1 ▶use base 'Reply::Plugin';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Time::HiRes qw(gettimeofday tv_interval);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12  
13 0 ▶sub new {
Subroutine new: not called CC=2 SCAR=17.9
Pod undocumented
14 0 my $class = shift;
15 0 my %opts = @_;
16  
17 0 my $self = $class->SUPER::new(@_);
18 0 ▶ $self->{mintime} = $opts{mintime} || 0.01;
Condition0%0/2
$opts{'mintime'} || 0.01
l!l
00
MC/DC0%0/1
$opts{'mintime'} || 0.01
$opts{'mintime'}
Truth table0%0/2
A
A= $opts{'mintime'}
Aresult
11
00
19  
20 0 return $self;
21 }
22  
23  
24 0 ▶sub execute {
Subroutine execute: not called CC=3 SCAR=24.8
Pod documented
25 0 my ($self, $next, @args) = @_;
26  
27 0 my $t0 = [gettimeofday];
28 0 my @ret = $next->(@args);
29 0 my $elapsed = tv_interval($t0);
30  
31 0 ▶ if ($elapsed > $self->{mintime}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elapsed > $self->{"mintime"}) 0 0 0
32 0 ▶ if ($elapsed >= 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($elapsed >= 1) { } 0 0 0
33 0 printf "Execution Time: %0.3fs\n", $elapsed
34 } else {
35 0 printf "Execution Time: %dms\n", $elapsed * 1000
36 }
37 }
38  
39 0 return @ret;
40 }
41  
42 1 1;
43  
44 __END__
« Reply/Plugin/ResultCache.pm ↑ Summary Reply/Plugin/Nopaste.pm »