Timer.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 4 totaltotal 0.0% 0 / 42 CC 2 SCAR 11.0
CC
2
Cov
0%
elapsed
6.0
start
2.0
stop
2.0
CRAP 3.0
1 package Sash::Timer;
2  
3 use strict;
4 use warnings;
5  
6 use Time::HiRes qw( gettimeofday tv_interval );
7  
8 my $_start;
9 my $_stop;
10  
11 sub start {
12 my $self = shift;
13 $_start = [ gettimeofday ];
14 $_stop = undef;
15 }
16  
17 sub stop {
18 my $self = shift;
19 $_stop = [ gettimeofday ];
20 }
21  
22 sub elapsed {
23 my $self = shift;
24 return undef unless ( $_start && $_stop );
25 return sprintf( "(%.2f sec)", tv_interval( $_start, $_stop ) );
26 }
27  
28 sub reset {
29 my $self = shift;
30 $_start = undef;
31 $_stop = undef;
32 }
33  
34  
35 1;