line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::Times; |
2
|
1
|
|
|
1
|
|
681
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
3
|
1
|
|
|
1
|
|
9
|
use warnings; |
|
1
|
|
|
|
|
12
|
|
|
1
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
409
|
use Test2::Util::Times qw/render_bench render_duration/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
59
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
|
|
44
|
use Test2::API qw{ |
8
|
|
|
|
|
|
|
test2_add_callback_exit |
9
|
1
|
|
|
1
|
|
7
|
}; |
|
1
|
|
|
|
|
2
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
6
|
use Time::HiRes qw/time/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.000155'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $ADDED_HOOK = 0; |
16
|
|
|
|
|
|
|
my $START; |
17
|
|
|
|
|
|
|
sub import { |
18
|
1
|
50
|
|
1
|
|
10
|
return if $ADDED_HOOK++; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
3
|
$START = time; |
21
|
1
|
|
|
|
|
4
|
test2_add_callback_exit(\&send_time_event); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub send_time_event { |
25
|
1
|
|
|
1
|
0
|
469
|
my ($ctx, $real, $new) = @_; |
26
|
1
|
|
|
|
|
5
|
my $stop = time; |
27
|
1
|
|
|
|
|
14
|
my @times = times(); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
6
|
my $summary = render_bench($START, $stop, @times); |
30
|
1
|
|
|
|
|
4
|
my $duration = render_duration($START, $stop); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
23
|
my $e = $ctx->send_ev2( |
33
|
|
|
|
|
|
|
about => {package => __PACKAGE__, details => $summary}, |
34
|
|
|
|
|
|
|
info => [{tag => 'TIME', details => $summary}], |
35
|
|
|
|
|
|
|
times => { |
36
|
|
|
|
|
|
|
details => $summary, |
37
|
|
|
|
|
|
|
start => $START, |
38
|
|
|
|
|
|
|
stop => $stop, |
39
|
|
|
|
|
|
|
user => $times[0], |
40
|
|
|
|
|
|
|
sys => $times[1], |
41
|
|
|
|
|
|
|
cuser => $times[2], |
42
|
|
|
|
|
|
|
csys => $times[3], |
43
|
|
|
|
|
|
|
}, |
44
|
|
|
|
|
|
|
harness_job_fields => [ |
45
|
|
|
|
|
|
|
{name => "time_duration", details => $duration}, |
46
|
|
|
|
|
|
|
{name => "time_user", details => $times[0]}, |
47
|
|
|
|
|
|
|
{name => "time_sys", details => $times[1]}, |
48
|
|
|
|
|
|
|
{name => "time_cuser", details => $times[2]}, |
49
|
|
|
|
|
|
|
{name => "time_csys", details => $times[3]}, |
50
|
|
|
|
|
|
|
], |
51
|
|
|
|
|
|
|
); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
__END__ |