| 1 | package Test::Class::Moose::Report::Time; | ||
| 2 | |||
| 3 | # ABSTRACT: Reporting object for timing | ||
| 4 | |||
| 5 | 30 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 30 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 30 | ▶ | use namespace::autoclean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 30 | ▶ | use 5.010000; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 30 | our $VERSION = '1.00'; | |
| 12 | |||
| 13 | 30 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 14 | 30 | ▶ | use Benchmark qw(timestr :hireswallclock); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 30 | ▶ | use List::Util qw( max ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | { | ||
| 18 | 30 | my @fields = qw( real user system ); | |
| 19 | 30 | for my $i ( 0 .. $#fields ) { | |
| 20 | has $fields[$i] => ( | ||
| 21 | is => 'ro', | ||
| 22 | isa => 'Num', | ||
| 23 | lazy => 1, | ||
| 24 | 651 | ▶ | default => sub { max( $_[0]->_timediff->[$i], 0 ) }, |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 25 | 90 | init_arg => undef, | |
| 26 | ); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | 30 | has '_timediff' => ( | |
| 31 | is => 'ro', | ||
| 32 | isa => 'Benchmark', | ||
| 33 | required => 1, | ||
| 34 | init_arg => 'timediff', | ||
| 35 | ); | ||
| 36 | |||
| 37 | 0 | ▶ | sub duration { |
|
Subroutine
duration: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 38 | 0 | my $self = shift; | |
| 39 | 0 | return timestr( $self->_timediff ); | |
| 40 | } | ||
| 41 | |||
| 42 | 217 | ▶ | sub as_hashref { |
|
Subroutine
as_hashref: called CC=1 SCAR=0.0
Pod
documented
| |||
| 43 | 217 | my $self = shift; | |
| 44 | 217 | return { map { $_ => $self->$_ } qw( real user system ) }; | |
| 45 | } | ||
| 46 | |||
| 47 | 30 | __PACKAGE__->meta->make_immutable; | |
| 48 | |||
| 49 | 30 | 1; | |
| 50 | |||
| 51 | __END__ | ||