File Coverage

blib/lib/Dancer/Timer.pm
Criterion Covered Total %
statement 23 23 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 3 3 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             package Dancer::Timer;
2             our $AUTHORITY = 'cpan:SUKRIA';
3             #ABSTRACT: a timer for Dancer
4             $Dancer::Timer::VERSION = '1.3520';
5 190     190   1998 use strict;
  190         394  
  190         5349  
6 190     190   987 use warnings;
  190         441  
  190         5028  
7 190     190   991 use base 'Dancer::Object';
  190         463  
  190         20494  
8 190     190   99600 use Time::HiRes 'gettimeofday', 'tv_interval';
  190         276012  
  190         966  
9              
10 190     190   38686 use Dancer::ModuleLoader;
  190         513  
  190         35063  
11             Dancer::Timer->attributes('start_time');
12              
13             sub init {
14 524     524 1 1062 my ($self) = @_;
15 524         2618 $self->start_time([gettimeofday()]);
16             }
17              
18             sub tick {
19 30     30 1 1000436 my ($self) = @_;
20 30         135 my $now = [gettimeofday()];
21 30         116 my $delay = tv_interval($self->start_time, $now);
22 30         762 return sprintf('%0f', $delay);
23             }
24              
25             sub to_string {
26 1     1 1 6 my ($self) = @_;
27 1         6 $self->tick;
28             }
29              
30             1;
31              
32             __END__