line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::DBIProfile; |
2
|
1
|
|
|
1
|
|
76781
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.002006'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
707
|
use DBI::Profile qw/dbi_profile_merge_nodes/; |
|
1
|
|
|
|
|
23088
|
|
|
1
|
|
|
|
|
64
|
|
8
|
1
|
|
|
1
|
|
8
|
use Test2::API qw/test2_add_callback_exit context/; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
9
|
1
|
|
|
1
|
|
502
|
use Test2::Util::Times qw/render_duration/; |
|
1
|
|
|
|
|
662
|
|
|
1
|
|
|
|
|
305
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $ADDED_HOOK = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
1
|
|
|
1
|
|
30
|
my $class = shift; |
15
|
1
|
|
|
|
|
3
|
my ($path) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
4
|
if (defined $path) { |
18
|
0
|
|
|
|
|
0
|
$ENV{DBI_PROFILE} = $path; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
1
|
|
50
|
|
|
12
|
$ENV{DBI_PROFILE} //= "!MethodClass"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
3
|
return if $ADDED_HOOK++; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
5
|
$DBI::Profile::ON_DESTROY_DUMP = undef; |
27
|
1
|
|
|
|
|
4
|
$DBI::Profile::ON_FLUSH_DUMP = undef; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
1
|
my $ran = 0; |
30
|
|
|
|
|
|
|
my $callback = sub { |
31
|
2
|
100
|
|
2
|
|
20868
|
return if $ran++; |
32
|
1
|
|
|
|
|
5
|
send_profile_event(@_); |
33
|
1
|
|
|
|
|
4
|
}; |
34
|
|
|
|
|
|
|
|
35
|
1
|
|
|
|
|
12
|
test2_add_callback_exit($callback); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# Fallback |
38
|
1
|
50
|
|
1
|
|
46908
|
eval 'END { local $?; my $ctx = context(); $callback->($ctx); $ctx->release }; 1' or die $@; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
112
|
|
|
1
|
|
|
|
|
30
|
|
|
1
|
|
|
|
|
89
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub send_profile_event { |
42
|
1
|
|
|
1
|
0
|
4
|
my ($ctx, $real, $new) = @_; |
43
|
|
|
|
|
|
|
|
44
|
1
|
50
|
|
|
|
4
|
my $p = $DBI::shared_profile or return; |
45
|
|
|
|
|
|
|
|
46
|
1
|
|
|
|
|
2
|
my $data = $p->{Data}; |
47
|
1
|
|
|
|
|
7
|
my ($summary) = $p->format; |
48
|
|
|
|
|
|
|
|
49
|
1
|
|
|
|
|
405
|
my @totals; |
50
|
1
|
|
|
|
|
9
|
dbi_profile_merge_nodes(\@totals, $data); |
51
|
1
|
|
|
|
|
4
|
my ($count, $time) = @totals; |
52
|
|
|
|
|
|
|
|
53
|
1
|
|
|
|
|
10
|
$ctx->send_ev2( |
54
|
|
|
|
|
|
|
dbi_profile => $data, |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
about => {package => __PACKAGE__, details => $summary}, |
57
|
|
|
|
|
|
|
info => [{tag => 'DBI-PROF', details => $summary}], |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
harness_job_fields => [ |
60
|
|
|
|
|
|
|
{name => "dbi_time", details => render_duration($time), raw => $time}, |
61
|
|
|
|
|
|
|
{name => "dbi_calls", details => $count}, |
62
|
|
|
|
|
|
|
], |
63
|
|
|
|
|
|
|
); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |