line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test2::Plugin::DBIProfile; |
2
|
1
|
|
|
1
|
|
70523
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.002003'; |
6
|
|
|
|
|
|
|
|
7
|
1
|
|
|
1
|
|
674
|
use DBI::Profile qw/dbi_profile_merge_nodes/; |
|
1
|
|
|
|
|
22148
|
|
|
1
|
|
|
|
|
73
|
|
8
|
1
|
|
|
1
|
|
13
|
use Test2::API qw/test2_add_callback_exit/; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
48
|
|
9
|
1
|
|
|
1
|
|
617
|
use Test2::Util::Times qw/render_duration/; |
|
1
|
|
|
|
|
689
|
|
|
1
|
|
|
|
|
262
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
my $ADDED_HOOK = 0; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub import { |
14
|
1
|
|
|
1
|
|
36
|
my $class = shift; |
15
|
1
|
|
|
|
|
3
|
my ($path) = @_; |
16
|
|
|
|
|
|
|
|
17
|
1
|
50
|
|
|
|
3
|
if (defined $path) { |
18
|
0
|
|
|
|
|
0
|
$ENV{DBI_PROFILE} = $path; |
19
|
|
|
|
|
|
|
} |
20
|
|
|
|
|
|
|
else { |
21
|
1
|
|
50
|
|
|
15
|
$ENV{DBI_PROFILE} //= "!MethodClass"; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
1
|
50
|
|
|
|
4
|
return if $ADDED_HOOK++; |
25
|
|
|
|
|
|
|
|
26
|
1
|
|
|
|
|
5
|
$DBI::Profile::ON_DESTROY_DUMP = undef; |
27
|
1
|
|
|
|
|
3
|
$DBI::Profile::ON_FLUSH_DUMP = undef; |
28
|
|
|
|
|
|
|
|
29
|
1
|
|
|
|
|
5
|
test2_add_callback_exit(\&send_profile_event); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub send_profile_event { |
33
|
1
|
|
|
1
|
0
|
19499
|
my ($ctx, $real, $new) = @_; |
34
|
|
|
|
|
|
|
|
35
|
1
|
50
|
|
|
|
5
|
my $p = $DBI::shared_profile or return; |
36
|
|
|
|
|
|
|
|
37
|
1
|
|
|
|
|
3
|
my $data = $p->{Data}; |
38
|
1
|
|
|
|
|
6
|
my ($summary) = $p->format; |
39
|
|
|
|
|
|
|
|
40
|
1
|
|
|
|
|
371
|
my @totals; |
41
|
1
|
|
|
|
|
10
|
dbi_profile_merge_nodes(\@totals, $data); |
42
|
1
|
|
|
|
|
3
|
my ($count, $time) = @totals; |
43
|
|
|
|
|
|
|
|
44
|
1
|
|
|
|
|
13
|
$ctx->send_ev2( |
45
|
|
|
|
|
|
|
dbi_profile => $data, |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
about => {package => __PACKAGE__, details => $summary}, |
48
|
|
|
|
|
|
|
info => [{tag => 'DBI-PROF', details => $summary}], |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
harness_job_fields => [ |
51
|
|
|
|
|
|
|
{name => "dbi_time", details => render_duration($time), raw => $time}, |
52
|
|
|
|
|
|
|
{name => "dbi_calls", details => $count}, |
53
|
|
|
|
|
|
|
], |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
1; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__END__ |