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.3521';
5 190     190   1839 use strict;
  190         404  
  190         5343  
6 190     190   935 use warnings;
  190         402  
  190         4912  
7 190     190   1015 use base 'Dancer::Object';
  190         466  
  190         19916  
8 190     190   97562 use Time::HiRes 'gettimeofday', 'tv_interval';
  190         268610  
  190         1011  
9              
10 190     190   39353 use Dancer::ModuleLoader;
  190         498  
  190         33767  
11             Dancer::Timer->attributes('start_time');
12              
13             sub init {
14 524     524 1 1078 my ($self) = @_;
15 524         2569 $self->start_time([gettimeofday()]);
16             }
17              
18             sub tick {
19 30     30 1 1000261 my ($self) = @_;
20 30         128 my $now = [gettimeofday()];
21 30         112 my $delay = tv_interval($self->start_time, $now);
22 30         712 return sprintf('%0f', $delay);
23             }
24              
25             sub to_string {
26 1     1 1 5 my ($self) = @_;
27 1         4 $self->tick;
28             }
29              
30             1;
31              
32             __END__