| 1 | package B::Stats; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | our $VERSION = '0.09'; | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | # TODO | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # exact: probably use Opcodes and DynaLoader at BEGIN for c_minus. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # less overhead: do more in XS: _class, _count_op, _walkoptree_simple, _walksymtable | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # detect -E usage, features overhead | ||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | B::Stats - print optree statistics | ||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||
| 13 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||
| 15 | perl -MB::Stats myprog.pl # all | ||||||||||||||||||||||||||||||||||||||||||
| 16 | perl -MO=Stats myprog.pl # compile-time only | ||||||||||||||||||||||||||||||||||||||||||
| 17 | perl -MB::Stats[,OPTIONS] myprog.pl | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | Print statistics for all generated ops. | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | static analysis at compile-time, | ||||||||||||||||||||||||||||||||||||||||||
| 24 | static analysis at end-time to include all runtime added modules, | ||||||||||||||||||||||||||||||||||||||||||
| 25 | and dynamic analysis at run-time, as with a profiler. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | The purpose is to help you in your goal: | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | no bloat; | ||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | =head1 OPTIONS | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | Options can be bundled: C<-c,-e,-r> eq C<-cer> | ||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =item -c I<static> | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | Do static analysis at compile-time. This does not include all run-time require packages. | ||||||||||||||||||||||||||||||||||||||||||
| 40 | Invocation via -MO=Stats does this automatically. | ||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | =item -e I<end> | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | Do static analysis at end-time. This is includes all run-time require packages. | ||||||||||||||||||||||||||||||||||||||||||
| 45 | This calculates the heap space for the optree. | ||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | =item -r I<run> | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | Do dynamic run-time analysis of all actually visited ops, similar to a profiler. | ||||||||||||||||||||||||||||||||||||||||||
| 50 | Single ops can be called multiple times. | ||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||
| 52 | =item -a I<all (default)> | ||||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | Same as -cer: static compile-time, end-time and dynamic run-time. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | =item -t I<table> | ||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | Tabular list of -c, -e and -r results. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | =item -u I<summary> | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | Short summary only, no op class. | ||||||||||||||||||||||||||||||||||||||||||
| 63 | With -t only the final table(s). | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | =item -F I<Files> | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | Prints included file names | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =item -x I<fragmentation> B<NOT YET> | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | Calculates the optree I<fragmentation>. 0.0 is perfect, 1.0 is very bad. | ||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | A perfect optree has no null ops and every op->next is immediately next | ||||||||||||||||||||||||||||||||||||||||||
| 74 | to the op. | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | =item -f<op,...> I<filter> B<NOT YET> | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | Filter for op names and classes. Only calculate the given ops, resp. op class. | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | perl -MB::Stats,-fLOGOP,-fCOP,-fconcat myprog.pl | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | =item -lF<logfile> | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | Print output only to this file. Default: STDERR | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | perl -MB::Stats,-llog myprog.pl | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | our (%B_inc, %B_env); | ||||||||||||||||||||||||||||||||||||||||||
| 97 | BEGIN { %B_inc = %INC; } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | use strict; | ||||||||||||||||||||||||||||||||||||||||||
| 100 | # B includes 14 files and 3821 lines. overhead subtracted with B::Stats::Minus | ||||||||||||||||||||||||||||||||||||||||||
| 101 | use B; | ||||||||||||||||||||||||||||||||||||||||||
| 102 | use B::Stats::Minus; | ||||||||||||||||||||||||||||||||||||||||||
| 103 | # XSLoader adds 0 files and 0 lines, already with B. | ||||||||||||||||||||||||||||||||||||||||||
| 104 | # Changed to DynaLoader | ||||||||||||||||||||||||||||||||||||||||||
| 105 | # Opcodes-0.10 adds 6 files and 5303-3821 lines: Carp, AutoLoader, subs | ||||||||||||||||||||||||||||||||||||||||||
| 106 | # Opcodes-0.11 adds 2 files and 4141-3821 lines: subs | ||||||||||||||||||||||||||||||||||||||||||
| 107 | # use Opcodes; # deferred to run-time below | ||||||||||||||||||||||||||||||||||||||||||
| 108 | our ($static, @runtime, $compiled, $imported, $LOG); | ||||||||||||||||||||||||||||||||||||||||||
| 109 | my (%opt, $nops, $rops, @all_subs, $frag, %roots); | ||||||||||||||||||||||||||||||||||||||||||
| 110 | my ($c_count, $e_count, $r_count); | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | # check options | ||||||||||||||||||||||||||||||||||||||||||
| 113 | sub import { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | $DB::single = 1 if defined &DB::DB; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
import: not called CC=19 SCAR=59.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | #print STDERR "opt: ",join(',',@_),"; "; # for Debugging | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | for (@_) { # switch bundling without Getopt bloat | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | if (/^-?([acerxtFu])(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $opt{$1} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my $rest = $2; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | if ($rest =~ /^-?([acerxtFu])(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $opt{$1} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | $rest = $2; | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } while $rest; | ||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||
| 127 | # taking multiple arguments: -ffilter | ||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | if (/^-?f(.*)$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $arg = $1; | |||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | if ($arg =~ /^[A-Z_]*OP$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | my @optype = qw(BASEOP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP_OR_SVOP | |||||||||||||||||||||||||||||||||||||||||
| 132 | LOOP COP BASEOP_OR_UNOP FILESTATOP LOOPEXOP); | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $opt{f}->{class}->{$arg} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 134 | die "invalid B::Stats,-fOPCLASS argument: $arg\n" | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | unless grep {$arg eq $_} @optype; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | # pre-expand names for the class | ||||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | require Opcodes; | |||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | my $maxo = Opcodes::opcodes(); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | for my $i (0..$maxo-1) { | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my $name = Opcodes::opname($i); | |||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $class = $optype[ Opcodes::opclass($i) ]; | |||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | if ($class eq $arg) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $opt{f}->{name}->{$name} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } elsif ($arg =~ /^[a-z_]+$/) { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $opt{f}->{name}->{$arg} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | die "invalid B::Stats,-ffilter argument: $arg\n"; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | if (/^-?(l)(.*)$/) { # taking arguments: -llogfile | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $opt{$1} = $2; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | open $LOG, ">", $opt{l} or die "Cannot write to B::Stats,-llogfile: $opt{l}\n"; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $opt{a} = 1 if !$opt{c} and !$opt{e} and !$opt{r}; # default | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$opt{"c"} or $opt{"e"} or $opt{"r"}
$opt{"c"} or $opt{"e"}
MC/DC0%0/3
$opt{"c"} or $opt{"e"} or $opt{"r"}
$opt{"c"}
$opt{"e"}
$opt{"r"}
Truth table0%0/4
A or B or C
A= $opt{"c"}B= $opt{"e"}C= $opt{"r"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $opt{c} = $opt{e} = $opt{r} = 1 if $opt{a}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | #warn "%opt: ",keys %opt,"\n"; # for Debugging | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | $LOG = \*STDERR unless $opt{l}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | $imported = 1; | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | sub _class { | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | my $name = ref shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_class: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | $name =~ s/^.*:://; | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | # static | ||||||||||||||||||||||||||||||||||||||||||
| 172 | sub _count_op { | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | my $op = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_count_op: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | $nops++; # count also null ops | |||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ($$op) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $static->{name}->{$op->name}++; | |||||||||||||||||||||||||||||||||||||||||
| 177 | # $static->{class}->{_class($op)}++; | ||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | # collect subs and stashes before B is loaded | ||||||||||||||||||||||||||||||||||||||||||
| 182 | # XXX not yet used. we rather use B::Stats::Minus | ||||||||||||||||||||||||||||||||||||||||||
| 183 | sub _collect_env { | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | %B_env = { 'B::Stats' => 1 }; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_collect_env: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | _xs_collect_env() if $INC{'DynaLoader.pm'}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | # from B::Utils | ||||||||||||||||||||||||||||||||||||||||||
| 189 | our $sub; | ||||||||||||||||||||||||||||||||||||||||||
| 190 | sub B::GV::_mypush_starts { | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | my $name = $_[0]->STASH->NAME."::".$_[0]->SAFENAME; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mypush_starts: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | return unless ${$_[0]->CV}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $cv = $_[0]->CV; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ($cv->PADLIST->can("ARRAY") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$cv->PADLIST->can("ARRAY") and $cv->PADLIST->ARRAY and $cv->PADLIST->ARRAY->can("ARRAY")
$cv->PADLIST->can("ARRAY") and $cv->PADLIST->ARRAY
MC/DC0%0/3
$cv->PADLIST->can("ARRAY") and $cv->PADLIST->ARRAY and $cv->PADLIST->ARRAY->can("ARRAY")
$cv->PADLIST->can("ARRAY")
$cv->PADLIST->ARRAY
$cv->PADLIST->ARRAY->can("ARRAY")
Truth table0%0/4
A and B and C
A= $cv->PADLIST->can("ARRAY")B= $cv->PADLIST->ARRAYC= $cv->PADLIST->ARRAY->can("ARRAY")
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | and $cv->PADLIST->ARRAY | ||||||||||||||||||||||||||||||||||||||||||
| 196 | and $cv->PADLIST->ARRAY->can("ARRAY")) | ||||||||||||||||||||||||||||||||||||||||||
| 197 | { | ||||||||||||||||||||||||||||||||||||||||||
| 198 | push @all_subs, $_->ROOT | ||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | for grep { _class($_) eq "CV" } $cv->PADLIST->ARRAY->ARRAY; | |||||||||||||||||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | return unless ${$cv->START} and ${$cv->ROOT}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
${$cv->START;} and ${$cv->ROOT;}
MC/DC0%0/2
${$cv->START;} and ${$cv->ROOT;}
${$cv->START;}
${$cv->ROOT;}
Truth table0%0/3
A and B
A= ${$cv->START;}B= ${$cv->ROOT;}
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $roots{$name} = $cv->ROOT; | |||||||||||||||||||||||||||||||||||||||||
| 203 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub B::SPECIAL::_mypush_starts{} | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mypush_starts: not called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | sub _walkops { | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | ▶ | my ($callback, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_walkops: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 208 | # _collect_env() unless %B_env; | ||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | %roots = ( '__MAIN__' => B::main_root() ); | |||||||||||||||||||||||||||||||||||||||||
| 210 | _walksymtable(\%main::, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | '_mypush_starts', | ||||||||||||||||||||||||||||||||||||||||||
| 212 | sub { | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | ▶ | return if scalar grep {$_[0] eq $_."::"} ('B::Stats'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 215 | }, # Do not eat our own children! | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ''); | |||||||||||||||||||||||||||||||||||||||||
| 217 | push @all_subs, $_->ROOT | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | for grep { _class($_) eq "CV" } B::main_cv->PADLIST->ARRAY->ARRAY; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | for $sub (keys %roots) { | |||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | _walkoptree_simple($roots{$sub}, $callback, $data); | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | # catches __ANON__ | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | for (@all_subs) { | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | _walkoptree_simple($_, $callback, $data); | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | sub _walkoptree_simple { | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | my ($op, $callback, $data) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_walkoptree_simple: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $callback->($op,$data); | |||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | if ($$op && ($op->flags & B::OPf_KIDS)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$$op and $op->flags & 4
MC/DC0%0/2
$$op and $op->flags & 4
$$op
$op->flags & 4
Truth table0%0/3
A and B
A= $$opB= $op->flags & 4
| |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | ▶ | for (my $kid = $op->first; $$kid; $kid = $kid->sibling) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | _walkoptree_simple($kid, $callback, $data); | |||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | sub _walksymtable { | ||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | my ($symref, $method, $recurse, $prefix) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_walksymtable: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | my ($sym, $ref, $fullname); | |||||||||||||||||||||||||||||||||||||||||
| 241 | no strict 'refs'; | ||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | $prefix = '' unless defined $prefix; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | foreach my $sym (keys %$symref) { | |||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my $ref = $symref->{$sym}; | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | $fullname = "*main::".$prefix.$sym; | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($sym =~ /::$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $sym = $prefix . $sym; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | ▶ | if (B::svref_2object(\*$sym)->NAME ne "main::" && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
B::svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::" and &$recurse($sym)
B::svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::"
MC/DC0%0/3
B::svref_2object(\*$sym)->NAME ne "main::" and $sym ne "<none>::" and &$recurse($sym)
B::svref_2object(\*$sym)->NAME ne "main::"
$sym ne "<none>::"
&$recurse($sym)
Truth table0%0/4
A and B and C
A= B::svref_2object(\*$sym)->NAME ne "main::"B= $sym ne "<none>::"C= &$recurse($sym)
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | $sym ne "<none>::" && &$recurse($sym)) | ||||||||||||||||||||||||||||||||||||||||||
| 250 | { | ||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | _walksymtable(\%$fullname, $method, $recurse, $sym); | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | B::svref_2object(\*$fullname)->$method(); | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | =item compile | ||||||||||||||||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||||||||||||||||
| 261 | Static -c check at CHECK time. Triggered by -MO=Stats,-OPTS | ||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||
| 263 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | sub compile { | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | import(@_) unless $imported; # check options via O | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
compile: not called CC=2 SCAR=17.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | $compiled++; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | $opt{c} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 269 | return sub { | ||||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | $nops = 0; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | _walkops(\&_count_op); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | output($static, $nops, 'static compile-time'); | |||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | } | |||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||
| 276 | =item rcount ($opcode) | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | Returns run-time count per op type. | ||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | =item rcount_all() | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | Returns an AV ref for all opcounts, indexed by opcode. | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | =item reset_rcount() | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | Resets to opcount array for all ops to 0 | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | =item output ($count-hash, $ops, $name) | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | General formatter | ||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | sub output { | ||||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | ▶ | my ($count, $ops, $name) = @_; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: not called CC=26 SCAR=65.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | my %name = ( | |||||||||||||||||||||||||||||||||||||||||
| 298 | 'static compile-time' => 'c', | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 'static end-time' => 'e', | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 'dynamic run-time' => 'r' | ||||||||||||||||||||||||||||||||||||||||||
| 301 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $key = $name{$name}; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | my $lines = 0; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | my $inc = $key eq 'c' ? \%B_inc : \%INC; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | my $files = scalar keys %$inc; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | for (values %$inc) { | |||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | print $LOG $_,"\n" if $opt{F}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | open IN, "<", "$_"; | |||||||||||||||||||||||||||||||||||||||||
| 309 | # Todo: skip pod? | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | ▶ | while (<IN>) { chomp; s/#.*//; next if not length $_; $lines++; }; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | close IN; | |||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | for (qw(_files _lines _ops)) { | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | ▶ | $B::Stats::Minus::overhead->{$key}{$_} = 0 unless $B::Stats::Minus::overhead->{$key}{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | $files -= $B::Stats::Minus::overhead->{$key}{_files}; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $lines -= $B::Stats::Minus::overhead->{$key}{_lines}; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | $ops -= $B::Stats::Minus::overhead->{$key}{_ops}; | |||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | print $LOG "\nB::Stats $name:\nfiles=$files\tlines=$lines\tops=$ops\n"; | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | ▶ | return if $opt{t} and $opt{u}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"t"} and $opt{"u"}
MC/DC0%0/2
$opt{"t"} and $opt{"u"}
$opt{"t"}
$opt{"u"}
Truth table0%0/3
A and B
A= $opt{"t"}B= $opt{"u"}
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | print $LOG "\nop name:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | for (sort { $count->{name}->{$b} <=> $count->{name}->{$a} } | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | keys %{$count->{name}}) { | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $l = length $_; | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | my $c = $count->{name}->{$_}; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $c -= $B::Stats::Minus::overhead->{$key}{$_} if exists $B::Stats::Minus::overhead->{$key}{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $count->{name}->{$_} = $c; | |||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | next if $opt{f} and !$opt{f}->{name}->{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"name"}{$_}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"name"}{$_}
$opt{"f"}
not $opt{"f"}{"name"}{$_}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"name"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | ▶ | next if !$c; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | print $LOG $_, " " x (10-$l), "\t", $c, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||
| 333 | # FIXME: no OPCLASS overhead substraction | ||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | unless ($opt{u}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | print $LOG "\nop class:\n"; | |||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | require Opcodes; | |||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | my $maxo = Opcodes::opcodes(); | |||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my @optype = qw(BASEOP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP_OR_SVOP | |||||||||||||||||||||||||||||||||||||||||
| 340 | LOOP COP BASEOP_OR_UNOP FILESTATOP LOOPEXOP); | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 0 | for my $i (0..$maxo-1) { | |||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | my $name = Opcodes::opname($i); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if ($name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $class = $optype[ Opcodes::opclass($i) ]; | |||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | ▶ | next if $opt{f} and !$opt{f}->{name}->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"name"}{$name}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"name"}{$name}
$opt{"f"}
not $opt{"f"}{"name"}{$name}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"name"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | ▶ | next if $opt{f} and !$opt{f}->{class}->{$class}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"class"}{$class}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"class"}{$class}
$opt{"f"}
not $opt{"f"}{"class"}{$class}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"class"}{$class}
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $count->{class}->{ $class } += $count->{name}->{ $name }; | |||||||||||||||||||||||||||||||||||||||||
| 348 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | warn "invalid name for opcount[$i]"; | |||||||||||||||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||||||||||||||||
| 351 | } | ||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | for (sort { $count->{class}->{$b} <=> $count->{class}->{$a} } | |||||||||||||||||||||||||||||||||||||||||
| 353 | 0 | keys %{$count->{class}}) { | |||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | ▶ | next if $opt{f} and !$opt{f}->{class}->{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"class"}{$_}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"class"}{$_}
$opt{"f"}
not $opt{"f"}{"class"}{$_}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"class"}{$_}
| |||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | ▶ | next if !$count->{class}->{$_}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | my $l = length $_; | |||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | print $LOG $_, " " x (10-$l), "\t", $count->{class}->{$_}, "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | } | ||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | $count; | |||||||||||||||||||||||||||||||||||||||||
| 361 | } | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | =item output_runtime | ||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||
| 365 | -r formatter. | ||||||||||||||||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||||||||||||||||
| 367 | Prepares count hash from the runtime generated structure in XS and calls output(). | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | sub output_runtime { | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | $r_count = {}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_runtime: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | my $r_countarr = $_[0]; | |||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | #require DynaLoader; | ||||||||||||||||||||||||||||||||||||||||||
| 376 | #our @ISA = ('DynaLoader'); | ||||||||||||||||||||||||||||||||||||||||||
| 377 | #DynaLoader::bootstrap('B::Stats', $VERSION); | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | require Opcodes; | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | my $maxo = Opcodes::opcodes(); | |||||||||||||||||||||||||||||||||||||||||
| 380 | # @optype only since 5.8.9 in B | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | my @optype = qw(BASEOP UNOP BINOP LOGOP LISTOP PMOP SVOP PADOP PVOP_OR_SVOP | |||||||||||||||||||||||||||||||||||||||||
| 382 | LOOP COP BASEOP_OR_UNOP FILESTATOP LOOPEXOP); | ||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | for my $i (0..$maxo-1) { | |||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | ▶ | if (my $count = $r_countarr->[$i]) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $name = Opcodes::opname($i); | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | ▶ | if ($name) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $class = $optype[ Opcodes::opclass($i) ]; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | next if $opt{f} and !$opt{f}->{name}->{$name}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"name"}{$name}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"name"}{$name}
$opt{"f"}
not $opt{"f"}{"name"}{$name}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"name"}{$name}
| |||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | next if $opt{f} and !$opt{f}->{class}->{$class}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"class"}{$class}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"class"}{$class}
$opt{"f"}
not $opt{"f"}{"class"}{$class}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"class"}{$class}
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $r_count->{name}->{ $name } += $count; | |||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | $rops += $count; | |||||||||||||||||||||||||||||||||||||||||
| 392 | # $r_count->{class}->{ $class } += $count; | ||||||||||||||||||||||||||||||||||||||||||
| 393 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | warn "invalid name for opcount[$i]"; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | } | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $r_count = output($r_count, $rops, 'dynamic run-time'); | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | =item output_table | ||||||||||||||||||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||||||||||||||||
| 403 | -t formatter | ||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||
| 405 | Does not work together with -r | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | sub _output_tline { | ||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | ▶ | my $n = shift; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_output_tline: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | my $name = $n.(" "x(12-length($n))); | |||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | ▶ | return if $opt{f} and !$opt{f}->{name}->{$n}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"f"} and not $opt{"f"}{"name"}{$n}
MC/DC0%0/2
$opt{"f"} and not $opt{"f"}{"name"}{$n}
$opt{"f"}
not $opt{"f"}{"name"}{$n}
Truth table0%0/3
A and not(B)
A= $opt{"f"}B= not $opt{"f"}{"name"}{$n}
| |||||||||||||||||||||||||||||||||||||||||||
| 413 | my ($c, $e, $r) = ($c_count->{name}->{$n}, | ||||||||||||||||||||||||||||||||||||||||||
| 414 | $e_count->{name}->{$n}, | ||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $r_count->{name}->{$n}); | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | ▶ | return if !$c and !$e and !$r; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$c or $e or $r
$c or $e
MC/DC0%0/3
$c or $e or $r
$c
$e
$r
Truth table0%0/4
A or B or C
A= $cB= $eC= $r
| |||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | print $LOG join("\t", ($name, $c, $e, $r)), "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||||||||||||||||
| 420 | sub output_table { | ||||||||||||||||||||||||||||||||||||||||||
| 421 | # XXX we have empty runops runs with format. | ||||||||||||||||||||||||||||||||||||||||||
| 422 | #my $x = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 423 | #for (keys %{$r_count->{name}}) { | ||||||||||||||||||||||||||||||||||||||||||
| 424 | # $x++ if $r_count->{name}->{$_}; | ||||||||||||||||||||||||||||||||||||||||||
| 425 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 426 | #return unless $x; | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | ▶ | print $LOG " | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output_table: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 428 | B::Stats table: | ||||||||||||||||||||||||||||||||||||||||||
| 429 | -c -e -r | ||||||||||||||||||||||||||||||||||||||||||
| 430 | "; | ||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | warn "Cannot use -t with -r only\n" if !$opt{c} and !$opt{e}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$opt{"c"} or $opt{"e"}
MC/DC0%0/2
$opt{"c"} or $opt{"e"}
$opt{"c"}
$opt{"e"}
Truth table0%0/3
A or B
A= $opt{"c"}B= $opt{"e"}
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | if ($e_count and %$e_count) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$e_count and %$e_count
MC/DC0%0/2
$e_count and %$e_count
$e_count
%$e_count
Truth table0%0/3
A and B
A= $e_countB= %$e_count
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | for (sort { $e_count->{name}->{$b} <=> $e_count->{name}->{$a} } | |||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | keys %{$e_count->{name}}) { | |||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | _output_tline($_); | |||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||
| 437 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | for (sort { $c_count->{name}->{$b} <=> $c_count->{name}->{$a} } | |||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | keys %{$c_count->{name}}) { | |||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | _output_tline($_); | |||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||||||||||||||||
| 443 | } | ||||||||||||||||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||||||||||||||||
| 445 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | # Called not via -MO=Stats, rather -MB::Stats | ||||||||||||||||||||||||||||||||||||||||||
| 450 | CHECK { | ||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | compile->() if !$compiled and $opt{c}; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CHECK: not called CC=3 SCAR=24.8
Branch: 1 branch
Condition0%0/3
not $B::Stats::compiled and $opt{"c"}
MC/DC0%0/2
not $B::Stats::compiled and $opt{"c"}
not $B::Stats::compiled
$opt{"c"}
Truth table0%0/3
not(A) and B
A= not $B::Stats::compiledB= $opt{"c"}
| |||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||
| 453 | |||||||||||||||||||||||||||||||||||||||||||
| 454 | sub _end { #void _end($refToArrOfRuntimeCounts) | ||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $c_count = $static; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_end: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | if ($opt{e}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $nops = 0; | |||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $static = {}; | |||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | _walkops(\&_count_op); | |||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $e_count = output($static, $nops, 'static end-time'); | |||||||||||||||||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | output_runtime($_[0]) if $opt{r}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | if ( $opt{t} and ($] < 5.014 or ${^GLOBAL_PHASE} ne 'DESTRUCT') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$opt{"t"} and $] < "5.014" || ${^GLOBAL_PHASE} ne "DESTRUCT"
$] < "5.014" or ${^GLOBAL_PHASE} ne "DESTRUCT"
MC/DC0%0/3
$opt{"t"} and $] < "5.014" || ${^GLOBAL_PHASE} ne "DESTRUCT"
$opt{"t"}
$] < "5.014"
${^GLOBAL_PHASE} ne "DESTRUCT"
Truth table0%0/4
A and B or C
A= $opt{"t"}B= $] < "5.014"C= ${^GLOBAL_PHASE} ne "DESTRUCT"
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | output_table; | |||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | =head1 LICENSE | ||||||||||||||||||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||||||||||||||||
| 470 | This module is available under the same licences as perl, the Artistic | ||||||||||||||||||||||||||||||||||||||||||
| 471 | license and the GPL. | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||
| 475 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | XSLoader::load 'B::Stats', $VERSION; | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 1; | ||||||||||||||||||||||||||||||||||||||||||