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.3514_04'; # TRIAL
5             $Dancer::Timer::VERSION = '1.351404';
6 191     191   1997 use strict;
  191         310  
  191         4448  
7 191     191   809 use warnings;
  191         335  
  191         5031  
8 191     191   805 use base 'Dancer::Object';
  191         329  
  191         17862  
9 191     191   77213 use Time::HiRes 'gettimeofday', 'tv_interval';
  191         217183  
  191         717  
10              
11 191     191   31231 use Dancer::ModuleLoader;
  191         366  
  191         27361  
12             Dancer::Timer->attributes('start_time');
13              
14             sub init {
15 527     527 1 949 my ($self) = @_;
16 527         2520 $self->start_time([gettimeofday()]);
17             }
18              
19             sub tick {
20 30     30 1 1000227 my ($self) = @_;
21 30         104 my $now = [gettimeofday()];
22 30         92 my $delay = tv_interval($self->start_time, $now);
23 30         615 return sprintf('%0f', $delay);
24             }
25              
26             sub to_string {
27 1     1 1 3 my ($self) = @_;
28 1         3 $self->tick;
29             }
30              
31             1;
32              
33             __END__