line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::Times; |
2
|
1
|
|
|
1
|
|
659
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
382
|
use Test2::Util::Times qw/render_bench render_duration/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
61
|
|
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
|
|
43
|
use Test2::API qw{ |
8
|
|
|
|
|
|
|
test2_add_callback_exit |
9
|
1
|
|
|
1
|
|
7
|
}; |
|
1
|
|
|
|
|
1
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5
|
use Time::HiRes qw/time/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
14
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.000153'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $ADDED_HOOK = 0; |
16
|
|
|
|
|
|
|
my $START; |
17
|
|
|
|
|
|
|
sub import { |
18
|
1
|
50
|
|
1
|
|
10
|
return if $ADDED_HOOK++; |
19
|
|
|
|
|
|
|
|
20
|
1
|
|
|
|
|
5
|
$START = time; |
21
|
1
|
|
|
|
|
3
|
test2_add_callback_exit(\&send_time_event); |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub send_time_event { |
25
|
1
|
|
|
1
|
0
|
497
|
my ($ctx, $real, $new) = @_; |
26
|
1
|
|
|
|
|
5
|
my $stop = time; |
27
|
1
|
|
|
|
|
17
|
my @times = times(); |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
8
|
my $summary = render_bench($START, $stop, @times); |
30
|
1
|
|
|
|
|
8
|
my $duration = render_duration($START, $stop); |
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
|
|
25
|
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__ |