| 1 | package Dancer::Timer; | ||
| 2 | 223 | our $AUTHORITY = 'cpan:SUKRIA'; | |
| 3 | #ABSTRACT: a timer for Dancer | ||
| 4 | 223 | $Dancer::Timer::VERSION = '1.3520'; | |
| 5 | 223 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 223 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 223 | ▶ | use base 'Dancer::Object'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 223 | ▶ | use Time::HiRes 'gettimeofday', 'tv_interval'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 223 | ▶ | use Dancer::ModuleLoader; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 11 | 223 | Dancer::Timer->attributes('start_time'); | |
| 12 | |||
| 13 | sub init { | ||
| 14 | 528 | ▶ | my ($self) = @_; |
|
Subroutine
init: called CC=1 SCAR=0.0
Pod
documented
| |||
| 15 | 528 | $self->start_time([gettimeofday()]); | |
| 16 | } | ||
| 17 | |||
| 18 | sub tick { | ||
| 19 | 38 | ▶ | my ($self) = @_; |
|
Subroutine
tick: called CC=1 SCAR=0.0
Pod
documented
| |||
| 20 | 38 | my $now = [gettimeofday()]; | |
| 21 | 38 | my $delay = tv_interval($self->start_time, $now); | |
| 22 | 38 | return sprintf('%0f', $delay); | |
| 23 | } | ||
| 24 | |||
| 25 | sub to_string { | ||
| 26 | 1 | ▶ | my ($self) = @_; |
|
Subroutine
to_string: called CC=1 SCAR=0.0
Pod
documented
| |||
| 27 | 1 | $self->tick; | |
| 28 | } | ||
| 29 | |||
| 30 | 223 | 1; | |
| 31 | |||
| 32 | __END__ | ||