line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Class::Moose::Role::HasTimeReport; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# ABSTRACT: Report timing role |
4
|
|
|
|
|
|
|
|
5
|
30
|
|
|
30
|
|
26255
|
use strict; |
|
30
|
|
|
|
|
94
|
|
|
30
|
|
|
|
|
1116
|
|
6
|
30
|
|
|
30
|
|
177
|
use warnings; |
|
30
|
|
|
|
|
91
|
|
|
30
|
|
|
|
|
969
|
|
7
|
30
|
|
|
30
|
|
183
|
use namespace::autoclean; |
|
30
|
|
|
|
|
77
|
|
|
30
|
|
|
|
|
237
|
|
8
|
|
|
|
|
|
|
|
9
|
30
|
|
|
30
|
|
2604
|
use 5.010000; |
|
30
|
|
|
|
|
103
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '0.99'; |
12
|
|
|
|
|
|
|
|
13
|
30
|
|
|
30
|
|
182
|
use Moose::Role; |
|
30
|
|
|
|
|
77
|
|
|
30
|
|
|
|
|
273
|
|
14
|
30
|
|
|
30
|
|
196851
|
use Benchmark qw(timediff timestr :hireswallclock); |
|
30
|
|
|
|
|
155376
|
|
|
30
|
|
|
|
|
279
|
|
15
|
30
|
|
|
30
|
|
25752
|
use Test::Class::Moose::Report::Time; |
|
30
|
|
|
|
|
154
|
|
|
30
|
|
|
|
|
10683
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has '_start_benchmark' => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Benchmark', |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
default => sub { Benchmark->new }, |
22
|
|
|
|
|
|
|
predicate => '_has_start_benchmark', |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has '_end_benchmark' => ( |
26
|
|
|
|
|
|
|
is => 'ro', |
27
|
|
|
|
|
|
|
isa => 'Benchmark', |
28
|
|
|
|
|
|
|
lazy => 1, |
29
|
|
|
|
|
|
|
default => sub { Benchmark->new }, |
30
|
|
|
|
|
|
|
predicate => '_has_end_benchmark', |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'time' => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => 'Test::Class::Moose::Report::Time', |
36
|
|
|
|
|
|
|
lazy => 1, |
37
|
|
|
|
|
|
|
builder => '_build_time', |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# If Time::HiRes is available these will be non-integers |
41
|
|
|
|
|
|
|
has 'start_time' => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
isa => 'Num', |
44
|
|
|
|
|
|
|
lazy => 1, |
45
|
|
|
|
|
|
|
default => sub { $_[0]->_start_benchmark->[0] }, |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has 'end_time' => ( |
49
|
|
|
|
|
|
|
is => 'ro', |
50
|
|
|
|
|
|
|
isa => 'Num', |
51
|
|
|
|
|
|
|
lazy => 1, |
52
|
|
|
|
|
|
|
default => sub { $_[0]->_end_benchmark->[0] }, |
53
|
|
|
|
|
|
|
); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub _build_time { |
56
|
236
|
|
|
236
|
|
477
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# If we don't have start & end marked we'll return a report with zero time |
59
|
|
|
|
|
|
|
# elapsed. |
60
|
236
|
100
|
66
|
|
|
9170
|
unless ( $self->_has_start_benchmark && $self->_has_end_benchmark ) { |
61
|
3
|
|
|
|
|
29
|
my $benchmark = Benchmark->new; |
62
|
3
|
|
|
|
|
100
|
return Test::Class::Moose::Report::Time->new( |
63
|
|
|
|
|
|
|
timediff => timediff( $benchmark, $benchmark ) ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
233
|
|
|
|
|
7513
|
return Test::Class::Moose::Report::Time->new( timediff => |
67
|
|
|
|
|
|
|
timediff( $self->_end_benchmark, $self->_start_benchmark ) ); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=encoding UTF-8 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Test::Class::Moose::Role::HasTimeReport - Report timing role |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.99 |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 DESCRIPTION |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Note that everything in here is experimental and subject to change. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 REQUIRES |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
None. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head1 PROVIDED |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
=head2 C<time> |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
Returns a L<Test::Class::Moose::Report::Time> object. This object represents |
101
|
|
|
|
|
|
|
the duration of this class or method. The duration may be "0" if it's an |
102
|
|
|
|
|
|
|
abstract class with no tests run. |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head2 C<start_time> |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Returns the start time for the report as an epoch value. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head2 C<end_time> |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Returns the end time for the report as an epoch value. |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 SUPPORT |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
Bugs may be submitted at L<https://github.com/houseabsolute/test-class-moose/issues>. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 SOURCE |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
The source code repository for Test-Class-Moose can be found at L<https://github.com/houseabsolute/test-class-moose>. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHORS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Curtis "Ovid" Poe <ovid@cpan.org> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=back |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
This software is copyright (c) 2012 - 2021 by Curtis "Ovid" Poe. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
141
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The full text of the license can be found in the |
144
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=cut |