Trace/Entry.pm

filter: Statementstmt 84.1% 69 / 82 Branchbran 59.0% 26 / 44 Conditioncond 42.8% 6 / 14 MC/DCmcdc 22.2% 2 / 9 Subroutinesub 80.0% 8 / 10 Podpod 80.0% 4 / 5 totaltotal 70.1% 115 / 164 CC 31 SCAR 27.6
CC
31
Cov
72%
values
24.2
parse
18.6
stats
6.0
CRAP 15.8
↑ Summary Trace/Header.pm »
1 #
2 # $Id: Entry.pm,v 1.9 2003/12/24 20:38:54 oratrc Exp $
3 #
4 package Oracle::Trace::Entry;
5  
6 1 ▶use 5.008001;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use Oracle::Trace::Chunk;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 1 our @ISA = qw(Oracle::Trace::Chunk);
13  
14 1 our $VERSION = do { my @r = (q$Revision: 1.9 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
15  
16 1 ▶my $DEBUG = $ENV{Oracle_Trace_DEBUG} || 0;
Condition50%1/2
$ENV{'Oracle_Trace_DEBUG'} || 0
l!l
01
MC/DC0%0/1
$ENV{'Oracle_Trace_DEBUG'} || 0
$ENV{'Oracle_Trace_DEBUG'}
Truth table50%1/2
A
A= $ENV{'Oracle_Trace_DEBUG'}
Aresult
11
00
17  
18 # Chunk
19  
20 25 ▶sub parse {
Subroutine parse: called CC=17 SCAR=29.2
Pod documented
21 25 my $self = shift;
22 25 my $data = shift;
23 25 ▶ $self->debug("incoming: ".Dumper($data)) if $DEBUG >= 4;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG >= 4 0 25 25
24 25 my $i_line = 0;
25 25 ▶ if ($data) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data) 25 0 25
26 LINE:
27 25 foreach my $line (split("\n", $data)) {
28 303 ▶ $self->debug("line[".$i_line."] $line") if $DEBUG >= 5;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG >= 5 0 303 303
29 303 $i_line++;
30 303 ▶ next LINE if $line =~ /^(\*\*\*\s+\d+|END OF STMT)/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^(\*\*\*\s+\d+|END OF STMT)/ 29 274 303
31 274 ▶ if ($line =~ /^(STAT|WAIT)\s+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(STAT|WAIT)\s+/) 39 235 274
32 39 ▶ next LINE unless $self->{_extended};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_extended"} 39 0 39
33 }
34 235 ▶ if ($line =~ /dep=[1-9]+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /dep=[1-9]+/) 197 38 235
35 197 $self->{_child}++;
36 197 ▶ next LINE unless $self->{_recurse};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_recurse"} 197 0 197
37 }
38 # expecting uppercase words preceding data - misses binds
39 38 ▶ if ($line =~ /^([A-Z]+(?:\s+[A-Z]+)*\s*(?:\#\d+)*):*(.*)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^([A-Z]+(?:\s+[A-Z]+)*\s*(?:\#\d+)*):*(.*)$/) { } 12 26 38
40 12 my ($k, $v) = ($1, $2);
41 12 ▶ if (my %data = ($v =~ /([a-z]+)=(\d+|'[^']*')/g)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my(%data) = $v =~ /([a-z]+)=(\d+|'[^']*')/g) 12 0 12
42 12 push @{$self->{_data}->{$k}}, \%data;
43 12 ▶ if ($k =~ /^PARSING IN CURSOR/ && defined($data{dep})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^PARSING IN CURSOR/ and defined $data{"dep"}) 3 9 12
Condition66%2/3
$k =~ /^PARSING IN CURSOR/ and defined $data{"dep"}
!ll&&!rl&&r
903
MC/DC50%1/2
$k =~ /^PARSING IN CURSOR/ and defined $data{"dep"}
$k =~ /^PARSING IN CURSOR/ defined $data{"dep"}
Truth table66%2/3
A and B
A= $k =~ /^PARSING IN CURSOR/B= defined $data{"dep"}
ABresult
0X0
100
111
44 3 ▶ $self->{_parent}++ if $data{dep} == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $data{"dep"} == 0 3 0 3
45 }
46 }
47 } else {
48 26 push @{$self->{_data}{other}}, $line;
49 }
50 }
51 }
52 25 ▶ $self->debug("_data: ".Dumper($self->{_data})) if $DEBUG >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG >= 3 0 25 25
53 25 ▶ $self->debug("lines read: $i_line") if $DEBUG >= 2;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG >= 2 0 25 25
54 25 return $self;
55 }
56  
57 =item values
58  
59 Return the values from the hash referenced by the type and key given, with optional value or index.
60  
61 @vals = $o_chk->values('type' => 'PARSE #\d+', 'key' => 'dep', 'value' => '0');
62  
63 =cut
64  
65 32 ▶sub values {
Subroutine values: called CC=12 SCAR=31.9
Pod documented
66 32 my $self = shift;
67 32 my %h = (
68 'type' => 'PARSE .+',
69 'key' => '.+',
70 'value' => '.+',
71 'index' => '',
72 @_);
73 32 my @vals = ();
74 32 ▶ unless (($h{type}) and ($h{key})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h{'type'} and $h{'key'}) { } 32 0 32
Condition33%1/3
$h{"type"} and $h{"key"}
!ll&&!rl&&r
0032
MC/DC0%0/2
$h{"type"} and $h{"key"}
$h{"type"} $h{"key"}
Truth table33%1/3
A and B
A= $h{"type"}B= $h{"key"}
ABresult
0X0
100
111
75 0 $self->error("invalid type and key: ".Dumper(\%h));
76 } else {
77 32 foreach my $k (grep(/$h{type}/, $self->keys)) {
78 23 my $i_ind = 0;
79 23 ▶ if ($h{index} =~ /\d+/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($h{'index'} =~ /\d+/) { } 0 23 23
80 0 ▶ if ($h{type} eq 'other') {
Branch: 1 branch
BranchTrueFalseTotal
if ($h{'type'} eq 'other') { } 0 0 0
81 0 @vals = grep(/$h{value}/, @{$self->{_data}{$k}[$h{index}]});
82 } else {
83 0 ▶ if (defined($self->{_data}{$k}[$h{index}]->{$h{key}}) &&
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} and $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} =~ /($h{"value"})/) 0 0 0
Condition0%0/3
defined $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} and $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} =~ /($h{"value"})/
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} and $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} =~ /($h{"value"})/
defined $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} =~ /($h{"value"})/
Truth table0%0/3
A and B
A= defined $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}}B= $self->{"_data"}{$k}[$h{"index"}]{$h{"key"}} =~ /($h{"value"})/
ABresult
0X0
100
111
84 $self->{_data}{$k}[$h{index}]->{$h{key}} =~ /($h{value})/) {
85 0 push(@vals, $1);
86 }
87 }
88 } else {
89 23 ▶ if ($h{type} eq 'other') {
Branch: 1 branch
BranchTrueFalseTotal
if ($h{'type'} eq 'other') { } 12 11 23
90 12 @vals = grep(/$h{value}/, @{$self->{_data}{$k}});
91 } else {
92 11 foreach my $h_d (@{$self->{_data}{$k}}) {
93 12 ▶ push(@vals, $1) if (defined($h_d->{$h{key}}) && $h_d->{$h{key}} =~ /($h{value})/);
Branch: 1 branch
BranchTrueFalseTotal
if defined $$h_d{$h{"key"}} and $$h_d{$h{"key"}} =~ /($h{"value"})/ 11 1 12
Condition66%2/3
defined $$h_d{$h{"key"}} and $$h_d{$h{"key"}} =~ /($h{"value"})/
!ll&&!rl&&r
1011
MC/DC50%1/2
defined $$h_d{$h{"key"}} and $$h_d{$h{"key"}} =~ /($h{"value"})/
defined $$h_d{$h{"key"}} $$h_d{$h{"key"}} =~ /($h{"value"})/
Truth table66%2/3
A and B
A= defined $$h_d{$h{"key"}}B= $$h_d{$h{"key"}} =~ /($h{"value"})/
ABresult
0X0
100
111
94 }
95 }
96 }
97 }
98 }
99  
100 32 return @vals;
101 }
102  
103 =item elapsed
104  
105 Return a total of the C<elapsed> times for this C<Entry>.
106  
107 my $elapsed = $o_ent->elapsed;
108  
109 =cut
110  
111 4 ▶sub elapsed {
Subroutine elapsed: called CC=3 SCAR=11.0
Pod documented
112 4 my $self = shift;
113 4 my $elapsed = 0;
114  
115 4 my @parse = $self->values('type'=>'PARSE.+', 'key'=>'e');
116 4 my @exec = $self->values('type'=>'EXEC.+', 'key'=>'e');
117 4 my @fetch = $self->values('type'=>'FETCH.+', 'key'=>'e');
118 4 ▶ $self->debug("p(@parse) e(@exec) f(@fetch)") if $DEBUG >= 3;
Branch: 1 branch
BranchTrueFalseTotal
if $DEBUG >= 3 0 4 4
119  
120 4 foreach my $x (@parse, @exec, @fetch) {
121 7 $elapsed += $x;
122 }
123  
124 4 return $elapsed;
125 }
126  
127 =item stats
128  
129 Synonmy for C<statistics()>
130  
131 =cut
132  
133 0 ▶sub statistics { return $_[0]->stats; }
Subroutine statistics: not called CC=1 SCAR=6.9
Pod undocumented
134  
135 0 ▶sub stats {
Subroutine stats: not called CC=2 SCAR=17.9
Pod documented
136 0 my $self = shift;
137 0 my @stats = ();
138 0 ▶ unless ($self->{_extended}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_extended'}) { } 0 0 0
139 0 $self->fatal("extended statistics not enabled");
140 } else {
141 0 @stats = $self->values('type'=>'STAT \#\d+','key'=>'op');
142 }
143 0 return @stats;
144 }
145  
146 1 1;
147  
148 __END__
↑ Summary Trace/Header.pm »