Bencher/Backend.pm

filter: Statementstmt 3.3% 66 / 1986 Branchbran 0.0% 0 / 864 Conditioncond 0.0% 0 / 617 MC/DCmcdc 0.0% 0 / 330 Subroutinesub 10.5% 17 / 161 Podpod 100% 5 / 5 totaltotal 2.2% 88 / 3963 CC 781 SCAR 100.9
CC
781
Cov
2%
bencher
63666.7
_gen_items
22650.0
_filter_records
18090.0
CRAP 24047.5
↑ Summary Bencher/Role/FieldMunger.pm »
1 ## no critic: Subroutines::ProhibitExplicitReturnUndef InputOutput::ProhibitInteractiveTest
2 package Bencher::Backend;
3  
4 3 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use Log::ger;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 3 ▶use Data::Dmp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 3 ▶use List::MoreUtils qw(all);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 3 ▶use List::Util qw(first);
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 3 ▶use Exporter qw(import);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 3 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
16 3 our $DATE = '2023-07-08'; # DATE
17 3 our $DIST = 'Bencher-Backend'; # DIST
18 3 our $VERSION = '1.063'; # VERSION
19  
20 3 our @EXPORT_OK = qw(
21 bencher
22 format_result
23 chart_result
24 split_result
25 parse_scenario
26 );
27  
28 3 our %SPEC;
29  
30 0 ▶sub _ver_or_vers {
Subroutine _ver_or_vers: not called CC=2 SCAR=17.9
31 0 my $v = shift;
32 0 ▶ if (ref($v) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $v eq 'ARRAY') { } 0 0 0
33 0 return join(", ", @$v);
34 } else {
35 0 return $v;
36 }
37 }
38  
39 0 ▶sub _get_tempfile_path {
Subroutine _get_tempfile_path: not called CC=3 SCAR=24.8
40 0 my ($args, $filename) = @_;
41 0 state $tempdir = do {
42 0 require File::Temp;
43 0 ▶ File::Temp::tempdir(CLEANUP => $args->{keep_tempdir} || log_is_debug() ? 0:1);
Branch: 1 branch
BranchTrueFalseTotal
$args->{'keep_tempdir'} || log_is_debug() ? : 0 0 0
Condition0%0/3
$args->{"keep_tempdir"} or log_is_debug()
l!l&&r!l&&!r
000
MC/DC0%0/2
$args->{"keep_tempdir"} or log_is_debug()
$args->{"keep_tempdir"} log_is_debug()
Truth table0%0/3
A or B
A= $args->{"keep_tempdir"}B= log_is_debug()
ABresult
1X1
011
000
44 };
45 0 "$tempdir/$filename";
46 }
47  
48 0 ▶sub _maybe_tidy_script {
Subroutine _maybe_tidy_script: not called CC=3 SCAR=24.8
49 0 require IPC::System::Options;
50  
51 0 my ($args, $path) = @_;
52 0 ▶ return unless $args->{tidy};
Branch: 1 branch
BranchTrueFalseTotal
unless $args->{"tidy"} 0 0 0
53 0 my $rand = int(1_000_000*rand());
54 0 ▶ rename $path, "$path.$rand" or die "Can't rename $path -> $path.$rand: $!";
Branch: 1 branch
BranchTrueFalseTotal
rename $path, "$path.$rand" or die "Can't rename $path -> $path.${rand}: $!" 0 0 0
55 0 IPC::System::Options::system(
56 {log=>1, die=>1},
57 "perltidy", "$path.$rand", "-o", $path,
58 );
59 }
60  
61 0 ▶sub _fill_template {
Subroutine _fill_template: not called CC=5 SCAR=29.4
62 3 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
63 0 my ($template, $vars, $escape_method) = @_;
64  
65 0 ▶ if ($escape_method eq 'shell') {
Branch: 1 branch
BranchTrueFalseTotal
if ($escape_method eq "shell") 0 0 0
66 0 require String::ShellQuote;
67 }
68  
69 0 $template =~ s/\<(\w+)(:raw)?\>/
70 $2 eq ':raw' ? $vars->{$1} :
71 $escape_method eq 'shell' ? String::ShellQuote::shell_quote($vars->{$1}) :
72 $escape_method eq 'dmp' ? dmp($vars->{$1}) :
73 0 ▶ $vars->{$1}
Branch: 3 branches
BranchTrueFalseTotal
$2 eq ':raw' ? : 0 0 0
$escape_method eq 'shell' ? : 0 0 0
$escape_method eq 'dmp' ? : 0 0 0
74 /eg;
75  
76 0 $template;
77 }
78  
79 0 ▶sub _get_process_size {
Subroutine _get_process_size: not called CC=12 SCAR=50.5
80 0 my ($args, $parsed, $it) = @_;
81  
82 0 my $script_path = _get_tempfile_path($args, "get_process_size-$it->{seq}");
83  
84 0 log_debug("Creating script to measure get process size at %s ...", $script_path);
85 {
86 0 ▶ open my($fh), ">", $script_path or die "Can't open file $script_path: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $script_path or die "Can't open file ${script_path}: $!" 0 0 0
87  
88 0 print $fh "# load modules\n";
89 0 my $participants = $parsed->{participants};
90 0 my $participant = _find_record_by_seq($participants, $it->{_permute}{participant});
91 0 ▶ if ($participant->{module}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($participant->{'module'}) { } 0 0 0
elsif ($participant->{'modules'}) { } 0 0 0
92 0 print $fh "require $participant->{module};\n";
93 } elsif ($participant->{modules}) {
94 0 print $fh "require $_;\n" for @{ $participant->{modules} };
95 }
96 0 ▶ if ($participant->{helper_modules}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($participant->{"helper_modules"}) 0 0 0
97 0 print $fh "require $_;\n" for @{ $participant->{helper_modules} };
98 }
99 # XXX should we load extra_modules? i think we should
100 0 print $fh "\n";
101  
102 0 print $fh "# run code\n";
103 0 print $fh 'my $code = ', dmp($it->{_code}), '; $code->(); ', "\n";
104 0 print $fh "\n";
105  
106 # we don't want to load extra modules like Linux::Smaps etc because they
107 # will increase the process size themselves. instead, we do it very
108 # minimally by reading /proc/PID/smaps directly. this means it will only
109 # work for linux. support for other OS should be added here.
110 0 print $fh "# get process size\n";
111 0 print $fh 'print "### OUTPUT-TO-PARSE-BY-BENCHER ###\n";', "\n"; # keep sync with reading code
112 0 print $fh 'my %stats;', "\n";
113 0 print $fh 'open my($fh), "<", "/proc/$$/smaps" or die "Cannot open /proc/$$smaps: $!";', "\n";
114 0 print $fh 'while (<$fh>) { /^(\w+):\s*(\d+)/ or next; $stat{lc $1} += $2 }', "\n";
115 0 print $fh 'for (sort keys %stat) { print "$_: $stat{$_}\n" }', "\n";
116 0 print $fh "\n";
117  
118 0 ▶ close $fh or die "Can't write to $script_path: $!";
Branch: 1 branch
BranchTrueFalseTotal
close $fh or die "Can't write to ${script_path}: $!" 0 0 0
119 0 _maybe_tidy_script($args, $script_path);
120 }
121  
122 # run the script
123 {
124 0 require Capture::Tiny;
125 0 my @cmd = ($^X, $script_path);
126 0 log_debug("Running %s ...", \@cmd);
127 0 ▶ my ($stdout, @res) = &Capture::Tiny::capture_stdout(sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
128 0 system @cmd;
129 0 ▶ die "Failed running script '$script_path' to get process size" if $?;
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
130 0 });
131 0 ▶ $stdout =~ /^### OUTPUT-TO-PARSE-BY-BENCHER ###(.+)/ms
Branch: 1 branch
BranchTrueFalseTotal
$stdout =~ /^### OUTPUT-TO-PARSE-BY-BENCHER ###(.+)/ms or die "Can't find marker in output of '${script_path}' to get process size" 0 0 0
132 or die "Can't find marker in output of '$script_path' to get process size";
133 0 my $info0 = $1;
134 0 ▶ my %info; while ($info0 =~ /^(\w+): (\d+)/gm) { $info{$1} = $2 }
Branch: 1 branch
BranchTrueFalseTotal
if ($info0 =~ /^(\w+): (\d+)/gm) 0 0 0
135 0 $it->{"proc_size"} = $info{size}*1024;
136 0 for (qw/rss private_dirty/) {
137 0 ▶ $it->{"proc_${_}_size"} = $info{$_}*1024 if defined $info{$_};
Branch: 1 branch
BranchTrueFalseTotal
if defined $info{$_} 0 0 0
138 }
139 }
140 }
141  
142 0 ▶sub _find_record_by_seq {
Subroutine _find_record_by_seq: not called CC=3 SCAR=24.8
143 0 my ($recs, $seq) = @_;
144  
145 0 for my $rec (@$recs) {
146 0 ▶ return $rec if $rec->{seq} == $seq;
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"seq"} == $seq 0 0 0
147 }
148 0 undef;
149 }
150  
151 0 ▶sub _filter_records {
Subroutine _filter_records: not called CC=134 SCAR=98.0
152 0 my %args = @_;
153  
154 0 my $recs = $args{records};
155 0 my $entity = $args{entity};
156 0 my $include = $args{include};
157 0 my $exclude = $args{exclude};
158 0 my $include_name = $args{include_name};
159 0 my $exclude_name = $args{exclude_name};
160 0 my $include_seq = $args{include_seq};
161 0 my $exclude_seq = $args{exclude_seq};
162 0 my $include_pattern = $args{include_pattern};
163 0 my $exclude_pattern = $args{exclude_pattern};
164 0 my $include_tags = $args{include_tags};
165 0 my $exclude_tags = $args{exclude_tags};
166 0 ▶ my $aibdf = $args{apply_include_by_default_filter} // 1;
Condition0%0/2
$args{"apply_include_by_default_filter"} // 1
l!l
00
MC/DC0%0/1
$args{"apply_include_by_default_filter"} // 1
$args{"apply_include_by_default_filter"}
Truth table0%0/2
A
A= $args{"apply_include_by_default_filter"}
Aresult
11
00
167  
168 0 my $frecs = [];
169  
170 # check that there is a name that is also a sequence number which could be
171 # confusing
172 {
173 0 ▶ last unless $include || $exclude ||
Branch: 1 branch
BranchTrueFalseTotal
unless $include or $exclude or $include_pattern or $exclude_pattern 0 0 0
Condition0%0/9
$include or $exclude or $include_pattern or $exclude_pattern
l!l&&r!l&&!r
000
$include or $exclude or $include_pattern
l!l&&r!l&&!r
000
$include or $exclude
l!l&&r!l&&!r
000
MC/DC0%0/4
$include or $exclude or $include_pattern or $exclude_pattern
$include $exclude $include_pattern $exclude_pattern
Truth table0%0/5
A or B or C or D
A= $includeB= $excludeC= $include_patternD= $exclude_pattern
ABCDresult
1XXX1
01XX1
001X1
00011
00000
174 $include_pattern || $exclude_pattern;
175 0 my @seq_names;
176 0 for my $rec (@$recs) {
177 0 ▶ my $name = $rec->{name} // $rec->{_name};
Condition0%0/3
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$rec->{"name"} // $rec->{"_name"}
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
178 0 ▶ next unless $name =~ /\A\d+\z/ && $name < @$recs;
Branch: 1 branch
BranchTrueFalseTotal
unless $name =~ /\A\d+\z/ and $name < @$recs 0 0 0
Condition0%0/3
$name =~ /\A\d+\z/ and $name < @$recs
!ll&&!rl&&r
000
MC/DC0%0/2
$name =~ /\A\d+\z/ and $name < @$recs
$name =~ /\A\d+\z/ $name < @$recs
Truth table0%0/3
A and B
A= $name =~ /\A\d+\z/B= $name < @$recs
ABresult
0X0
100
111
179 0 push @seq_names, $name;
180 }
181 0 ▶ if (@seq_names) {
Branch: 1 branch
BranchTrueFalseTotal
if (@seq_names) 0 0 0
182 0 warn "There is at least one $entity which has names that are also ".
183 "sequence numbers and this can be confusing when ".
184 "including/excluding: " . join(", ", @seq_names) .
185 ". Either rename the $entity or use ".
186 "--{include,exclude}-$entity-{name,seq}.\n";
187 }
188 }
189  
190 # check that what's mentioned in {in,ex}clude{,_name,_seq} are actually in
191 # the records
192 {
193 0 ▶ for my $incexc (@{$include // []}) {
Condition0%0/2
$include // []
l!l
00
MC/DC0%0/1
$include // []
$include
Truth table0%0/2
A
A= $include
Aresult
11
00
194 0 my $found;
195 0 for my $rec (@$recs) {
196 0 ▶ if ($incexc =~ /\A\d+\z/ && $rec->{seq} == $incexc) {
Branch: 2 branches
BranchTrueFalseTotal
if ($incexc =~ /\A\d+\z/ and $rec->{'seq'} == $incexc) { } 0 0 0
elsif ((($rec->{'name'} // $rec->{'_name'}) // '') eq $incexc) { } 0 0 0
Condition0%0/3
$incexc =~ /\A\d+\z/ and $rec->{"seq"} == $incexc
!ll&&!rl&&r
000
MC/DC0%0/2
$incexc =~ /\A\d+\z/ and $rec->{"seq"} == $incexc
$incexc =~ /\A\d+\z/ $rec->{"seq"} == $incexc
Truth table0%0/3
A and B
A= $incexc =~ /\A\d+\z/B= $rec->{"seq"} == $incexc
ABresult
0X0
100
111
197 0 $found++;
198 0 last;
199 ▶ } elsif (($rec->{name} // $rec->{_name} // '') eq $incexc) {
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
200 0 $found++;
201 0 last;
202 }
203 }
204 die "Unknown $entity '$incexc' specified in include, try ".
205 "one of: " .
206 join(", ",
207 0 grep { length($_) }
208 0 ▶ map { ($_->{seq},
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
209 0 ▶ $_->{name} // $_->{_name} // '') }
Condition0%0/5
($_->{"name"} // $_->{"_name"}) // ""
l!l
00
$_->{"name"} // $_->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($_->{"name"} // $_->{"_name"}) // ""
$_->{"name"} $_->{"_name"}
Truth table0%0/3
A // B
A= $_->{"name"}B= $_->{"_name"}
ABresult
1X1
011
000
210 @$recs)
211 unless $found;
212 }
213 0 ▶ for my $incexc (@{$exclude // []}) {
Condition0%0/2
$exclude // []
l!l
00
MC/DC0%0/1
$exclude // []
$exclude
Truth table0%0/2
A
A= $exclude
Aresult
11
00
214 0 my $found;
215 0 for my $rec (@$recs) {
216 0 ▶ if ($incexc =~ /\A\d+\z/ && $rec->{seq} == $incexc) {
Branch: 2 branches
BranchTrueFalseTotal
if ($incexc =~ /\A\d+\z/ and $rec->{'seq'} == $incexc) { } 0 0 0
elsif ((($rec->{'name'} // $rec->{'_name'}) // '') eq $incexc) { } 0 0 0
Condition0%0/3
$incexc =~ /\A\d+\z/ and $rec->{"seq"} == $incexc
!ll&&!rl&&r
000
MC/DC0%0/2
$incexc =~ /\A\d+\z/ and $rec->{"seq"} == $incexc
$incexc =~ /\A\d+\z/ $rec->{"seq"} == $incexc
Truth table0%0/3
A and B
A= $incexc =~ /\A\d+\z/B= $rec->{"seq"} == $incexc
ABresult
0X0
100
111
217 0 $found++;
218 0 last;
219 ▶ } elsif (($rec->{name} // $rec->{_name} // '') eq $incexc) {
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
220 0 $found++;
221 0 last;
222 }
223 }
224 die "Unknown $entity '$incexc' specified in exclude, try ".
225 "one of: " .
226 join(", ",
227 0 grep { length($_) }
228 0 ▶ map { ($_->{seq},
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
229 0 ▶ $_->{name} // $_->{_name} // '') }
Condition0%0/5
($_->{"name"} // $_->{"_name"}) // ""
l!l
00
$_->{"name"} // $_->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($_->{"name"} // $_->{"_name"}) // ""
$_->{"name"} $_->{"_name"}
Truth table0%0/3
A // B
A= $_->{"name"}B= $_->{"_name"}
ABresult
1X1
011
000
230 @$recs)
231 unless $found;
232 }
233 0 ▶ for my $incexc (@{$include_name // []}) {
Condition0%0/2
$include_name // []
l!l
00
MC/DC0%0/1
$include_name // []
$include_name
Truth table0%0/2
A
A= $include_name
Aresult
11
00
234 0 my $found;
235 0 for my $rec (@$recs) {
236 0 ▶ if (($rec->{name} // $rec->{_name} // '') eq $incexc) {
Branch: 1 branch
BranchTrueFalseTotal
if ((($rec->{"name"} // $rec->{"_name"}) // "") eq $incexc) 0 0 0
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
237 0 $found++;
238 0 last;
239 }
240 }
241 die "Unknown $entity name '$incexc' specified in include_name, try ".
242 "one of: " .
243 join(", ",
244 0 grep { length($_) }
245 0 ▶ map { $_->{name} // $_->{_name} // '' }
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
Condition0%0/5
($_->{"name"} // $_->{"_name"}) // ""
l!l
00
$_->{"name"} // $_->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($_->{"name"} // $_->{"_name"}) // ""
$_->{"name"} $_->{"_name"}
Truth table0%0/3
A // B
A= $_->{"name"}B= $_->{"_name"}
ABresult
1X1
011
000
246 @$recs)
247 unless $found;
248 }
249 0 ▶ for my $incexc (@{$exclude_name // []}) {
Condition0%0/2
$exclude_name // []
l!l
00
MC/DC0%0/1
$exclude_name // []
$exclude_name
Truth table0%0/2
A
A= $exclude_name
Aresult
11
00
250 0 my $found;
251 0 for my $rec (@$recs) {
252 0 ▶ if (($rec->{name} // $rec->{_name} // '') eq $incexc) {
Branch: 1 branch
BranchTrueFalseTotal
if ((($rec->{"name"} // $rec->{"_name"}) // "") eq $incexc) 0 0 0
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
253 0 $found++;
254 0 last;
255 }
256 }
257 die "Unknown $entity name '$incexc' specified in exclude_name, try ".
258 "one of: " .
259 join(", ",
260 0 grep { length($_) }
261 0 ▶ map { $_->{name} // $_->{_name} // '' }
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
Condition0%0/5
($_->{"name"} // $_->{"_name"}) // ""
l!l
00
$_->{"name"} // $_->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($_->{"name"} // $_->{"_name"}) // ""
$_->{"name"} $_->{"_name"}
Truth table0%0/3
A // B
A= $_->{"name"}B= $_->{"_name"}
ABresult
1X1
011
000
262 @$recs)
263 unless $found;
264 }
265 0 ▶ for my $incexc (@{$include_seq // []}) {
Condition0%0/2
$include_seq // []
l!l
00
MC/DC0%0/1
$include_seq // []
$include_seq
Truth table0%0/2
A
A= $include_seq
Aresult
11
00
266 0 my $found;
267 0 for my $rec (@$recs) {
268 0 ▶ if ($rec->{seq} == $incexc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"seq"} == $incexc) 0 0 0
269 0 $found++;
270 0 last;
271 }
272 }
273 die "Unknown $entity sequence '$incexc' specified in include_seq, try ".
274 0 ▶ "one of: " . join(", ", map { $_->{seq} } @$recs) unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
275 }
276 0 ▶ for my $incexc (@{$exclude_seq // []}) {
Condition0%0/2
$exclude_seq // []
l!l
00
MC/DC0%0/1
$exclude_seq // []
$exclude_seq
Truth table0%0/2
A
A= $exclude_seq
Aresult
11
00
277 0 my $found;
278 0 for my $rec (@$recs) {
279 0 ▶ if ($rec->{seq} == $incexc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"seq"} == $incexc) 0 0 0
280 0 $found++;
281 0 last;
282 }
283 }
284 die "Unknown $entity sequence '$incexc' specified in exclude_seq, try ".
285 0 ▶ "one of: " . join(", ", map { $_->{seq} } @$recs) unless $found;
Branch: 1 branch
BranchTrueFalseTotal
unless $found 0 0 0
286 }
287 }
288  
289 REC:
290 0 for my $rec (@$recs) {
291 0 my $explicitly_included;
292 0 ▶ if ($include && @$include) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include and @$include) 0 0 0
Condition0%0/3
$include and @$include
!ll&&!rl&&r
000
MC/DC0%0/2
$include and @$include
$include @$include
Truth table0%0/3
A and B
A= $includeB= @$include
ABresult
0X0
100
111
293 0 my $included;
294 INC:
295 0 for my $inc (@$include) {
296 0 ▶ if ($inc =~ /\A\d+\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($inc =~ /\A\d+\z/) 0 0 0
297 0 ▶ if ($rec->{seq} == $inc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"seq"} == $inc) 0 0 0
298 0 $included++;
299 0 last INC;
300 }
301 }
302 0 ▶ if (($rec->{name} // $rec->{_name} // '') eq $inc) {
Branch: 1 branch
BranchTrueFalseTotal
if ((($rec->{"name"} // $rec->{"_name"}) // "") eq $inc) 0 0 0
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
303 0 $included++;
304 0 last INC;
305 }
306 }
307 0 ▶ next REC unless $included;
Branch: 1 branch
BranchTrueFalseTotal
unless $included 0 0 0
308 0 $explicitly_included++;
309 }
310 0 ▶ if ($include_name && @$include_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_name and @$include_name) 0 0 0
Condition0%0/3
$include_name and @$include_name
!ll&&!rl&&r
000
MC/DC0%0/2
$include_name and @$include_name
$include_name @$include_name
Truth table0%0/3
A and B
A= $include_nameB= @$include_name
ABresult
0X0
100
111
311 0 my $included;
312 INC:
313 0 for my $inc (@$include_name) {
314 0 ▶ if (($rec->{name} // $rec->{_name} // '') eq $inc) {
Branch: 1 branch
BranchTrueFalseTotal
if ((($rec->{"name"} // $rec->{"_name"}) // "") eq $inc) 0 0 0
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
315 0 $included++;
316 0 last INC;
317 }
318 }
319 0 ▶ next REC unless $included;
Branch: 1 branch
BranchTrueFalseTotal
unless $included 0 0 0
320 0 $explicitly_included++;
321 }
322 0 ▶ if ($include_seq && @$include_seq) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_seq and @$include_seq) 0 0 0
Condition0%0/3
$include_seq and @$include_seq
!ll&&!rl&&r
000
MC/DC0%0/2
$include_seq and @$include_seq
$include_seq @$include_seq
Truth table0%0/3
A and B
A= $include_seqB= @$include_seq
ABresult
0X0
100
111
323 0 my $included;
324 INC:
325 0 for my $inc (@$include_seq) {
326 0 ▶ if ($rec->{seq} == $inc) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"seq"} == $inc) 0 0 0
327 0 $included++;
328 0 last INC;
329 }
330 }
331 0 ▶ next REC unless $included;
Branch: 1 branch
BranchTrueFalseTotal
unless $included 0 0 0
332 0 $explicitly_included++;
333 }
334 0 ▶ if ($exclude && @$exclude) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude and @$exclude) 0 0 0
Condition0%0/3
$exclude and @$exclude
!ll&&!rl&&r
000
MC/DC0%0/2
$exclude and @$exclude
$exclude @$exclude
Truth table0%0/3
A and B
A= $excludeB= @$exclude
ABresult
0X0
100
111
335 0 for my $exc (@$exclude) {
336 0 ▶ if ($exc =~ /\A\d+\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exc =~ /\A\d+\z/) { } 0 0 0
337 0 ▶ next REC if $rec->{seq} == $exc;
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"seq"} == $exc 0 0 0
338 } else {
339 0 ▶ next REC if (($rec->{name} // $rec->{_name} // '') eq $exc);
Branch: 1 branch
BranchTrueFalseTotal
if (($rec->{"name"} // $rec->{"_name"}) // "") eq $exc 0 0 0
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
340 }
341 }
342 }
343 0 ▶ if ($exclude_name && @$exclude_name) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude_name and @$exclude_name) 0 0 0
Condition0%0/3
$exclude_name and @$exclude_name
!ll&&!rl&&r
000
MC/DC0%0/2
$exclude_name and @$exclude_name
$exclude_name @$exclude_name
Truth table0%0/3
A and B
A= $exclude_nameB= @$exclude_name
ABresult
0X0
100
111
344 0 for my $exc (@$exclude_name) {
345 0 ▶ next REC if (($rec->{name} // $rec->{_name} // '') eq $exc);
Branch: 1 branch
BranchTrueFalseTotal
if (($rec->{"name"} // $rec->{"_name"}) // "") eq $exc 0 0 0
Condition0%0/5
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($rec->{"name"} // $rec->{"_name"}) // ""
$rec->{"name"} $rec->{"_name"}
Truth table0%0/3
A // B
A= $rec->{"name"}B= $rec->{"_name"}
ABresult
1X1
011
000
346 }
347 }
348 0 ▶ if ($exclude_seq && @$exclude_seq) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude_seq and @$exclude_seq) 0 0 0
Condition0%0/3
$exclude_seq and @$exclude_seq
!ll&&!rl&&r
000
MC/DC0%0/2
$exclude_seq and @$exclude_seq
$exclude_seq @$exclude_seq
Truth table0%0/3
A and B
A= $exclude_seqB= @$exclude_seq
ABresult
0X0
100
111
349 0 for my $exc (@$exclude_seq) {
350 0 ▶ next REC if $rec->{seq} == $exc;
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"seq"} == $exc 0 0 0
351 }
352 }
353 0 ▶ if ($include_pattern) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_pattern) 0 0 0
354 next REC unless $rec->{seq} =~ /$include_pattern/i ||
355 0 ▶ (($rec->{name} // $rec->{_name} // '') =~ /$include_pattern/i);
Branch: 1 branch
BranchTrueFalseTotal
unless $rec->{"seq"} =~ /$include_pattern/i or (($rec->{"name"} // $rec->{"_name"}) // "") =~ /$include_pattern/i 0 0 0
Condition0%0/8
$rec->{"seq"} =~ /$include_pattern/i or (($rec->{"name"} // $rec->{"_name"}) // "") =~ /$include_pattern/i
l!l&&r!l&&!r
000
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$rec->{"seq"} =~ /$include_pattern/i or (($rec->{"name"} // $rec->{"_name"}) // "") =~ /$include_pattern/i
$rec->{"seq"} =~ /$include_pattern/i $rec->{"name"} $rec->{"_name"}
Truth table0%0/4
A or B // C
A= $rec->{"seq"} =~ /$include_pattern/iB= $rec->{"name"}C= $rec->{"_name"}
ABCresult
1XX1
01X1
0011
0000
356 0 $explicitly_included++;
357 }
358 0 ▶ if ($exclude_pattern) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude_pattern) 0 0 0
359 next REC if $rec->{seq} =~ /$exclude_pattern/i ||
360 0 ▶ (($rec->{name} // $rec->{_name} // '') =~ /$exclude_pattern/i);
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"seq"} =~ /$exclude_pattern/i or (($rec->{"name"} // $rec->{"_name"}) // "") =~ /$exclude_pattern/i 0 0 0
Condition0%0/8
$rec->{"seq"} =~ /$exclude_pattern/i or (($rec->{"name"} // $rec->{"_name"}) // "") =~ /$exclude_pattern/i
l!l&&r!l&&!r
000
($rec->{"name"} // $rec->{"_name"}) // ""
l!l
00
$rec->{"name"} // $rec->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$rec->{"seq"} =~ /$exclude_pattern/i or (($rec->{"name"} // $rec->{"_name"}) // "") =~ /$exclude_pattern/i
$rec->{"seq"} =~ /$exclude_pattern/i $rec->{"name"} $rec->{"_name"}
Truth table0%0/4
A or B // C
A= $rec->{"seq"} =~ /$exclude_pattern/iB= $rec->{"name"}C= $rec->{"_name"}
ABCresult
1XX1
01X1
0011
0000
361 }
362 0 ▶ if ($include_tags && @$include_tags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($include_tags and @$include_tags) 0 0 0
Condition0%0/3
$include_tags and @$include_tags
!ll&&!rl&&r
000
MC/DC0%0/2
$include_tags and @$include_tags
$include_tags @$include_tags
Truth table0%0/3
A and B
A= $include_tagsB= @$include_tags
ABresult
0X0
100
111
363 0 my $included;
364 INCTAG:
365 0 for my $tag (@$include_tags) {
366 0 ▶ if ($tag =~ /&/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /&/) { } 0 0 0
367 0 $included = 1;
368 0 for my $simpletag (split /\s*&\s*/, $tag) {
369 0 ▶ unless (grep {$_ eq $simpletag} @{ $rec->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $simpletag;} @{$rec->{"tags"} // [];}) 0 0 0
Condition0%0/2
$rec->{"tags"} // []
l!l
00
MC/DC0%0/1
$rec->{"tags"} // []
$rec->{"tags"}
Truth table0%0/2
A
A= $rec->{"tags"}
Aresult
11
00
370 0 $included = 0;
371 0 next REC;
372 }
373 }
374 0 last INCTAG;
375 } else {
376 0 ▶ if (grep {$_ eq $tag} @{ $rec->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq $tag;} @{$rec->{"tags"} // [];}) 0 0 0
Condition0%0/2
$rec->{"tags"} // []
l!l
00
MC/DC0%0/1
$rec->{"tags"} // []
$rec->{"tags"}
Truth table0%0/2
A
A= $rec->{"tags"}
Aresult
11
00
377 0 $included++;
378 0 last INCTAG;
379 }
380 }
381 }
382 0 ▶ next REC unless $included;
Branch: 1 branch
BranchTrueFalseTotal
unless $included 0 0 0
383 0 $explicitly_included++;
384 }
385 0 ▶ if ($exclude_tags && @$exclude_tags) {
Branch: 1 branch
BranchTrueFalseTotal
if ($exclude_tags and @$exclude_tags) 0 0 0
Condition0%0/3
$exclude_tags and @$exclude_tags
!ll&&!rl&&r
000
MC/DC0%0/2
$exclude_tags and @$exclude_tags
$exclude_tags @$exclude_tags
Truth table0%0/3
A and B
A= $exclude_tagsB= @$exclude_tags
ABresult
0X0
100
111
386 EXCTAG:
387 0 for my $tag (@$exclude_tags) {
388 0 ▶ if ($tag =~ /&/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /&/) { } 0 0 0
389 0 for my $simpletag (split /\s*&\s*/, $tag) {
390 0 ▶ unless (grep {$_ eq $simpletag} @{ $rec->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq $simpletag;} @{$rec->{"tags"} // [];}) 0 0 0
Condition0%0/2
$rec->{"tags"} // []
l!l
00
MC/DC0%0/1
$rec->{"tags"} // []
$rec->{"tags"}
Truth table0%0/2
A
A= $rec->{"tags"}
Aresult
11
00
391 0 next EXCTAG;
392 }
393 }
394 0 next REC;
395 } else {
396 0 ▶ next REC if grep {$_ eq $tag} @{ $rec->{tags} // [] };
Branch: 1 branch
BranchTrueFalseTotal
if grep {$_ eq $tag;} @{$rec->{"tags"} // [];} 0 0 0
Condition0%0/2
$rec->{"tags"} // []
l!l
00
MC/DC0%0/1
$rec->{"tags"} // []
$rec->{"tags"}
Truth table0%0/2
A
A= $rec->{"tags"}
Aresult
11
00
397 }
398 }
399 }
400  
401 0 ▶ unless ($explicitly_included || !$aibdf) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($explicitly_included or not $aibdf) 0 0 0
Condition0%0/3
$explicitly_included or not $aibdf
l!l&&r!l&&!r
000
MC/DC0%0/2
$explicitly_included or not $aibdf
$explicitly_included not $aibdf
Truth table0%0/3
A or not(B)
A= $explicitly_includedB= not $aibdf
ABresult
1X1
011
000
402 next REC if defined($rec->{include_by_default}) &&
403 0 ▶ !$rec->{include_by_default};
Branch: 1 branch
BranchTrueFalseTotal
if defined $rec->{"include_by_default"} and not $rec->{"include_by_default"} 0 0 0
Condition0%0/3
defined $rec->{"include_by_default"} and not $rec->{"include_by_default"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $rec->{"include_by_default"} and not $rec->{"include_by_default"}
defined $rec->{"include_by_default"} not $rec->{"include_by_default"}
Truth table0%0/3
A and not(B)
A= defined $rec->{"include_by_default"}B= not $rec->{"include_by_default"}
ABresult
0X0
100
111
404 }
405  
406 0 push @$frecs, $rec;
407 }
408  
409 0 $frecs;
410 }
411  
412 0 ▶sub _get_scenario {
Subroutine _get_scenario: not called CC=17 SCAR=56.0
413 0 my %args = @_;
414  
415 0 my $pargs = $args{parent_args};
416  
417 0 my $scenario;
418 0 ▶ if (defined $pargs->{scenario_file}) {
Branch: 4 branches
BranchTrueFalseTotal
if (defined $pargs->{'scenario_file'}) { } 0 0 0
elsif (defined $pargs->{'scenario_module'}) { } 0 0 0
elsif (defined $pargs->{'cpanmodules_module'}) { } 0 0 0
elsif (defined $pargs->{'scenario'}) { } 0 0 0
419 0 $scenario = do $pargs->{scenario_file};
420 0 ▶ die "Can't load scenario file '$pargs->{scenario_file}': $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
421 } elsif (defined $pargs->{scenario_module}) {
422 0 my $m = $pargs->{scenario_module};
423 0 ▶ $m = "Bencher::Scenario::$m" unless $m =~ /\ABencher::Scenario::/;
Branch: 1 branch
BranchTrueFalseTotal
unless $m =~ /\ABencher::Scenario::/ 0 0 0
424 0 $m =~ s!/!::!g;
425 0 my $mp = $m; $mp =~ s!::!/!g; $mp .= ".pm";
426 {
427 0 local @INC = @INC;
428 0 ▶ unshift @INC, $_ for @{ $pargs->{include_path} // [] };
Condition0%0/2
$pargs->{"include_path"} // []
l!l
00
MC/DC0%0/1
$pargs->{"include_path"} // []
$pargs->{"include_path"}
Truth table0%0/2
A
A= $pargs->{"include_path"}
Aresult
11
00
429 0 require $mp;
430 }
431 3 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
432 0 $scenario = ${"$m\::scenario"};
433 } elsif (defined $pargs->{cpanmodules_module}) {
434 0 require Acme::CPANModulesUtil::Bencher;
435  
436 0 my $mod = "Acme::CPANModules::$pargs->{cpanmodules_module}";
437 my $res = Acme::CPANModulesUtil::Bencher::gen_bencher_scenario(
438 cpanmodule => $pargs->{cpanmodules_module},
439 0 );
440 0 ▶ die "Can't load scenario from an Acme::CPANModules module '$mod': ".
Branch: 1 branch
BranchTrueFalseTotal
unless $res->[0] == 200 0 0 0
441 "$res->[0] - $res->[1]" unless $res->[0] == 200;
442 0 $scenario = $res->[2];
443 } elsif (defined $pargs->{scenario}) {
444 0 $scenario = $pargs->{scenario};
445 } else {
446 0 $scenario = {
447 participants => [],
448 };
449 }
450  
451 0 ▶ if ($pargs->{participants}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"participants"}) 0 0 0
452 0 for (@{ $pargs->{participants} }) {
453 0 push @{ $scenario->{participants} }, $_;
454 }
455 }
456 0 ▶ if ($pargs->{datasets}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"datasets"}) 0 0 0
457 0 ▶ $scenario->{datasets} //= [];
Condition0%0/2
$scenario->{"datasets"} //= []
l!l
00
MC/DC0%0/1
$scenario->{"datasets"} //= []
$scenario->{"datasets"}
Truth table0%0/2
A
A= $scenario->{"datasets"}
Aresult
11
00
458 0 for (@{ $pargs->{datasets} }) {
459 0 push @{ $scenario->{datasets} }, $_;
460 }
461 }
462 0 ▶ if ($pargs->{env_hashes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"env_hashes"}) 0 0 0
463 0 for (@{ $pargs->{env_hashes} }) {
464 0 push @{ $scenario->{env_hashes} }, $_;
465 }
466 }
467 0 $scenario;
468 }
469  
470 0 ▶sub _parse_scenario {
Subroutine _parse_scenario: not called CC=75 SCAR=86.5
471 0 my %args = @_;
472  
473 0 my $unparsed = $args{scenario};
474 0 my $pargs = $args{parent_args};
475 0 ▶ my $apply_filters = $args{apply_filters} // 1;
Condition0%0/2
$args{"apply_filters"} // 1
l!l
00
MC/DC0%0/1
$args{"apply_filters"} // 1
$args{"apply_filters"}
Truth table0%0/2
A
A= $args{"apply_filters"}
Aresult
11
00
476 0 ▶ my $aibdf = $args{apply_include_by_default_filter} // 1; # skip items that have include_by_default=0
Condition0%0/2
$args{"apply_include_by_default_filter"} // 1
l!l
00
MC/DC0%0/1
$args{"apply_include_by_default_filter"} // 1
$args{"apply_include_by_default_filter"}
Truth table0%0/2
A
A= $args{"apply_include_by_default_filter"}
Aresult
11
00
477  
478 0 my $parsed = {%$unparsed}; # shallow copy
479  
480 0 ▶ if ($parsed->{before_parse_participants}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_parse_participants"}) 0 0 0
481 0 log_info("Executing before_parse_participants hook ...");
482 $parsed->{before_parse_participants}->(
483 hook_name => 'before_parse_participants',
484 scenario => $unparsed,
485 stash => $args{stash},
486 0 );
487 }
488 # normalize participants
489 {
490 0 $parsed->{participants} = [];
491 0 my $i = -1;
492 0 for my $p0 (@{ $unparsed->{participants} }) {
493 0 $i++;
494 0 my $p = { %$p0, seq=>$i };
495 0 ▶ $p->{include_by_default} //= 1;
Condition0%0/2
$p->{"include_by_default"} //= 1
l!l
00
MC/DC0%0/1
$p->{"include_by_default"} //= 1
$p->{"include_by_default"}
Truth table0%0/2
A
A= $p->{"include_by_default"}
Aresult
11
00
496 0 ▶ $p->{type} //= do {
Condition0%0/3
$p->{"type"} //= do { if ($p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"} or $p->{"perl_cmdline_template"}) { "command"; } else { "perl_code"; } }
l!l&&r!l&&!r
000
MC/DC0%0/2
$p->{"type"} //= do { if ($p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"} or $p->{"perl_cmdline_template"}) { "command"; } else { "perl_code"; } }
$p->{"type"} do { if ($p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"} or $p->{"perl_cmdline_template"}) { "command"; } else { "perl_code"; } }
Truth table0%0/3
A //= B
A= $p->{"type"}B= do { if ($p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"} or $p->{"perl_cmdline_template"}) { "command"; } else { "perl_code"; } }
ABresult
1X1
011
000
497 0 ▶ if ($p->{cmdline} || $p->{cmdline_template} ||
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{'cmdline'} or $p->{'cmdline_template'} or $p->{'perl_cmdline'} or $p->{'perl_cmdline_template'}) { } 0 0 0
Condition0%0/9
$p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"} or $p->{"perl_cmdline_template"}
l!l&&r!l&&!r
000
$p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"}
l!l&&r!l&&!r
000
$p->{"cmdline"} or $p->{"cmdline_template"}
l!l&&r!l&&!r
000
MC/DC0%0/4
$p->{"cmdline"} or $p->{"cmdline_template"} or $p->{"perl_cmdline"} or $p->{"perl_cmdline_template"}
$p->{"cmdline"} $p->{"cmdline_template"} $p->{"perl_cmdline"} $p->{"perl_cmdline_template"}
Truth table0%0/5
A or B or C or D
A= $p->{"cmdline"}B= $p->{"cmdline_template"}C= $p->{"perl_cmdline"}D= $p->{"perl_cmdline_template"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
498 $p->{perl_cmdline} || $p->{perl_cmdline_template}) {
499 0 'command';
500 } else {
501 0 'perl_code';
502 }
503 };
504 0 ▶ if ($p->{fcall_template}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"fcall_template"}) 0 0 0
505 0 ▶ if ($p->{fcall_template} =~ /\A
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"fcall_template"} =~ /\A (\w+(?:::\w+)*) (::|->) (\w+)/x) 0 0 0
506 (\w+(?:::\w+)*)
507 (::|->)
508 (\w+)/x) {
509 0 $p->{module} = $1;
510 0 $p->{function} = $3;
511 }
512 }
513  
514 # try to come up with a nicer name for the participant (not
515 # necessarily unique)
516 0 ▶ unless (defined($p->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $p->{"name"}) 0 0 0
517 0 ▶ if ($p->{type} eq 'command') {
Branch: 2 branches
BranchTrueFalseTotal
if ($p->{'type'} eq 'command') { } 0 0 0
elsif ($p->{'type'} eq 'perl_code') { } 0 0 0
518 my $c = $p->{cmdline} // $p->{cmdline_template} //
519 0 ▶ $p->{perl_cmdline} // $p->{perl_cmdline_template};
Condition0%0/9
(($p->{"cmdline"} // $p->{"cmdline_template"}) // $p->{"perl_cmdline"}) // $p->{"perl_cmdline_template"}
l!l&&r!l&&!r
000
($p->{"cmdline"} // $p->{"cmdline_template"}) // $p->{"perl_cmdline"}
l!l&&r!l&&!r
000
$p->{"cmdline"} // $p->{"cmdline_template"}
l!l&&r!l&&!r
000
MC/DC0%0/4
(($p->{"cmdline"} // $p->{"cmdline_template"}) // $p->{"perl_cmdline"}) // $p->{"perl_cmdline_template"}
$p->{"cmdline"} $p->{"cmdline_template"} $p->{"perl_cmdline"} $p->{"perl_cmdline_template"}
Truth table0%0/5
A // B // C // D
A= $p->{"cmdline"}B= $p->{"cmdline_template"}C= $p->{"perl_cmdline"}D= $p->{"perl_cmdline_template"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
520 0 ▶ if (ref($c) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $c eq 'ARRAY') { } 0 0 0
521 0 $p->{_name} = substr($c->[0], 0, 20);
522 } else {
523 0 $c =~ /(\S+)/;
524 0 $p->{_name} = substr($1, 0, 20);
525 }
526 } elsif ($p->{type} eq 'perl_code') {
527 0 ▶ if ($p->{function}) {
Branch: 5 branches
BranchTrueFalseTotal
if ($p->{'function'}) { } 0 0 0
elsif ($p->{'module'}) { } 0 0 0
elsif ($p->{'modules'}) { } 0 0 0
elsif ($p->{'code_template'}) { } 0 0 0
elsif ($p->{'fcall_template'}) { } 0 0 0
528 $p->{_name} =
529 ($p->{module} ? "$p->{module}::" : "").
530 0 ▶ $p->{function};
Branch: 1 branch
BranchTrueFalseTotal
$p->{'module'} ? : 0 0 0
531 } elsif ($p->{module}) {
532 0 $p->{_name} = $p->{module};
533 } elsif ($p->{modules}) {
534 0 $p->{_name} = join("+", @{$p->{modules}});
535 } elsif ($p->{code_template}) {
536 0 $p->{_name} = substr($p->{code_template}, 0, 64);
537 } elsif ($p->{fcall_template}) {
538 0 $p->{_name} = substr($p->{fcall_template}, 0, 64);
539 }
540 }
541 }
542  
543 0 push @{ $parsed->{participants} }, $p;
544 } # for each participant
545  
546 # filter participants by include/exclude module/function
547 0 ▶ if ($apply_filters) {
Branch: 1 branch
BranchTrueFalseTotal
if ($apply_filters) 0 0 0
548 0 ▶ if ($pargs->{include_modules} && @{ $pargs->{include_modules} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"include_modules"} and @{$pargs->{"include_modules"};}) 0 0 0
Condition0%0/3
$pargs->{"include_modules"} and @{$pargs->{"include_modules"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"include_modules"} and @{$pargs->{"include_modules"};}
$pargs->{"include_modules"} @{$pargs->{"include_modules"};}
Truth table0%0/3
A and B
A= $pargs->{"include_modules"}B= @{$pargs->{"include_modules"};}
ABresult
0X0
100
111
549 $parsed->{participants} = [grep {
550 0 my $p = $_;
551 0 ▶ (defined($p->{module}) && grep { $_ eq $p->{module} } @{ $pargs->{include_modules} }) ||
Condition0%0/3
defined $p->{"modules"} and &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"include_modules"};}; } , @{$$p{"modules"};})
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->{"modules"} and &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"include_modules"};}; } , @{$$p{"modules"};})
defined $p->{"modules"} &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"include_modules"};}; } , @{$$p{"modules"};})
Truth table0%0/3
A and B
A= defined $p->{"modules"}B= &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"include_modules"};}; } , @{$$p{"modules"};})
ABresult
0X0
100
111
552 0 ▶ (defined($p->{modules}) && (first { my $m = $_; grep { $_ eq $m } @{ $pargs->{include_modules} } } @{ $p->{modules} }))
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/6
defined $p->{'module'} && grep({$_ eq $p->{'module'};} @{$$pargs{'include_modules'};}) || defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'include_modules'};}; } , @{$$p{'modules'};})
l!l&&r!l&&!r
000
defined $p->{"module"} and grep {$_ eq $p->{"module"};} @{$$pargs{"include_modules"};}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $p->{'module'} && grep({$_ eq $p->{'module'};} @{$$pargs{'include_modules'};}) || defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'include_modules'};}; } , @{$$p{'modules'};})
defined $p->{"module"} grep {$_ eq $p->{"module"};} @{$$pargs{"include_modules"};} defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'include_modules'};}; } , @{$$p{'modules'};})
Truth table0%0/5
A and B || C
A= defined $p->{"module"}B= grep {$_ eq $p->{"module"};} @{$$pargs{"include_modules"};}C= defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'include_modules'};}; } , @{$$p{'modules'};})
ABCresult
11X1
0X11
1011
0X00
1000
553 0 } @{ $parsed->{participants} }];
554 }
555 0 ▶ if ($pargs->{exclude_modules} && @{ $pargs->{exclude_modules} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"exclude_modules"} and @{$pargs->{"exclude_modules"};}) 0 0 0
Condition0%0/3
$pargs->{"exclude_modules"} and @{$pargs->{"exclude_modules"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"exclude_modules"} and @{$pargs->{"exclude_modules"};}
$pargs->{"exclude_modules"} @{$pargs->{"exclude_modules"};}
Truth table0%0/3
A and B
A= $pargs->{"exclude_modules"}B= @{$pargs->{"exclude_modules"};}
ABresult
0X0
100
111
556 $parsed->{participants} = [grep {
557 0 my $p = $_;
558 0 ▶ !(defined($p->{module}) && grep { $_ eq $p->{module} } @{ $pargs->{exclude_modules} }) &&
Condition0%0/3
defined $p->{"modules"} and &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"exclude_modules"};}; } , @{$$p{"modules"};})
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->{"modules"} and &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"exclude_modules"};}; } , @{$$p{"modules"};})
defined $p->{"modules"} &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"exclude_modules"};}; } , @{$$p{"modules"};})
Truth table0%0/3
A and B
A= defined $p->{"modules"}B= &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{"exclude_modules"};}; } , @{$$p{"modules"};})
ABresult
0X0
100
111
559 0 ▶ !(defined($p->{modules}) && (first { my $m = $_; grep { $_ eq $m } @{ $pargs->{exclude_modules} } } @{ $p->{modules} }))
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/6
defined $p->{'module'} && grep({$_ eq $p->{'module'};} @{$$pargs{'exclude_modules'};}) || defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'exclude_modules'};}; } , @{$$p{'modules'};})
l!l&&r!l&&!r
000
defined $p->{"module"} and grep {$_ eq $p->{"module"};} @{$$pargs{"exclude_modules"};}
!ll&&!rl&&r
000
MC/DC0%0/3
defined $p->{'module'} && grep({$_ eq $p->{'module'};} @{$$pargs{'exclude_modules'};}) || defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'exclude_modules'};}; } , @{$$p{'modules'};})
defined $p->{"module"} grep {$_ eq $p->{"module"};} @{$$pargs{"exclude_modules"};} defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'exclude_modules'};}; } , @{$$p{'modules'};})
Truth table0%0/5
A and B || C
A= defined $p->{"module"}B= grep {$_ eq $p->{"module"};} @{$$pargs{"exclude_modules"};}C= defined $p->{'modules'} && &first(sub { my $m = $_; grep {$_ eq $m;} @{$$pargs{'exclude_modules'};}; } , @{$$p{'modules'};})
ABCresult
11X1
0X11
1011
0X00
1000
560 0 } @{ $parsed->{participants} }];
561 }
562 0 ▶ if ($pargs->{include_module_pattern}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"include_module_pattern"}) 0 0 0
563 $parsed->{participants} = [grep {
564 0 my $p = $_;
565 (defined($p->{module}) && $p->{module} =~ qr/$pargs->{include_module_pattern}/i) ||
566 0 ▶ (defined($p->{modules}) && (first { /$pargs->{include_module_pattern}/i } @{ $p->{modules} }))
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/9
defined $p->{'module'} && $p->{'module'} =~ qr/$pargs->{'include_module_pattern'}/i || defined $p->{'modules'} && &first(sub { /$pargs->{'include_module_pattern'}/i; } , @{$$p{'modules'};})
l!l&&r!l&&!r
000
defined $p->{"module"} and $p->{"module"} =~ qr/$pargs->{"include_module_pattern"}/i
!ll&&!rl&&r
000
defined $p->{"modules"} and &first(sub { /$pargs->{"include_module_pattern"}/i; } , @{$$p{"modules"};})
!ll&&!rl&&r
000
MC/DC0%0/4
defined $p->{'module'} && $p->{'module'} =~ qr/$pargs->{'include_module_pattern'}/i || defined $p->{'modules'} && &first(sub { /$pargs->{'include_module_pattern'}/i; } , @{$$p{'modules'};})
defined $p->{"module"} $p->{"module"} =~ qr/$pargs->{"include_module_pattern"}/i defined $p->{"modules"} &first(sub { /$pargs->{"include_module_pattern"}/i; } , @{$$p{"modules"};})
Truth table0%0/7
A and B || C and D
A= defined $p->{"module"}B= $p->{"module"} =~ qr/$pargs->{"include_module_pattern"}/iC= defined $p->{"modules"}D= &first(sub { /$pargs->{"include_module_pattern"}/i; } , @{$$p{"modules"};})
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
567 0 } @{ $parsed->{participants} }];
568 }
569 0 ▶ if ($pargs->{exclude_module_pattern}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"exclude_module_pattern"}) 0 0 0
570 $parsed->{participants} = [grep {
571 0 my $p = $_;
572 !(defined($p->{module}) && $p->{module} =~ qr/$pargs->{exclude_module_pattern}/i) &&
573 0 ▶ !(defined($p->{modules}) && (first { /$pargs->{exclude_module_pattern}/i } @{ $p->{modules} }))
Subroutine __ANON__: not called CC=1 SCAR=6.9
Condition0%0/9
defined $p->{'module'} && $p->{'module'} =~ qr/$pargs->{'exclude_module_pattern'}/i || defined $p->{'modules'} && &first(sub { /$pargs->{'exclude_module_pattern'}/i; } , @{$$p{'modules'};})
l!l&&r!l&&!r
000
defined $p->{"module"} and $p->{"module"} =~ qr/$pargs->{"exclude_module_pattern"}/i
!ll&&!rl&&r
000
defined $p->{"modules"} and &first(sub { /$pargs->{"exclude_module_pattern"}/i; } , @{$$p{"modules"};})
!ll&&!rl&&r
000
MC/DC0%0/4
defined $p->{'module'} && $p->{'module'} =~ qr/$pargs->{'exclude_module_pattern'}/i || defined $p->{'modules'} && &first(sub { /$pargs->{'exclude_module_pattern'}/i; } , @{$$p{'modules'};})
defined $p->{"module"} $p->{"module"} =~ qr/$pargs->{"exclude_module_pattern"}/i defined $p->{"modules"} &first(sub { /$pargs->{"exclude_module_pattern"}/i; } , @{$$p{"modules"};})
Truth table0%0/7
A and B || C and D
A= defined $p->{"module"}B= $p->{"module"} =~ qr/$pargs->{"exclude_module_pattern"}/iC= defined $p->{"modules"}D= &first(sub { /$pargs->{"exclude_module_pattern"}/i; } , @{$$p{"modules"};})
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
574 0 } @{ $parsed->{participants} }];
575 }
576  
577 0 ▶ if ($pargs->{include_functions} && @{ $pargs->{include_functions} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"include_functions"} and @{$pargs->{"include_functions"};}) 0 0 0
Condition0%0/3
$pargs->{"include_functions"} and @{$pargs->{"include_functions"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"include_functions"} and @{$pargs->{"include_functions"};}
$pargs->{"include_functions"} @{$pargs->{"include_functions"};}
Truth table0%0/3
A and B
A= $pargs->{"include_functions"}B= @{$pargs->{"include_functions"};}
ABresult
0X0
100
111
578 $parsed->{participants} = [grep {
579 0 my $p = $_;
580 0 ▶ defined($p->{function}) && grep { $_ eq $p->{function} } @{ $pargs->{include_functions} }
Condition0%0/3
defined $p->{'function'} && grep({$_ eq $p->{'function'};} @{$$pargs{'include_functions'};})
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->{'function'} && grep({$_ eq $p->{'function'};} @{$$pargs{'include_functions'};})
defined $p->{'function'} grep({$_ eq $p->{'function'};} @{$$pargs{'include_functions'};})
Truth table0%0/3
A && B
A= defined $p->{'function'}B= grep({$_ eq $p->{'function'};} @{$$pargs{'include_functions'};})
ABresult
0X0
100
111
581 0 } @{ $parsed->{participants} }];
582 }
583 0 ▶ if ($pargs->{exclude_functions} && @{ $pargs->{exclude_functions} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"exclude_functions"} and @{$pargs->{"exclude_functions"};}) 0 0 0
Condition0%0/3
$pargs->{"exclude_functions"} and @{$pargs->{"exclude_functions"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"exclude_functions"} and @{$pargs->{"exclude_functions"};}
$pargs->{"exclude_functions"} @{$pargs->{"exclude_functions"};}
Truth table0%0/3
A and B
A= $pargs->{"exclude_functions"}B= @{$pargs->{"exclude_functions"};}
ABresult
0X0
100
111
584 0 my $p = $_;
585 $parsed->{participants} = [grep {
586 0 ▶ !defined($p->{function}) || !(grep {$_ eq $p->{function} } @{ $pargs->{exclude_functions} })
Condition0%0/3
defined $p->{'function'} && grep({$_ eq $p->{'function'};} @{$$pargs{'exclude_functions'};})
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->{'function'} && grep({$_ eq $p->{'function'};} @{$$pargs{'exclude_functions'};})
defined $p->{'function'} grep({$_ eq $p->{'function'};} @{$$pargs{'exclude_functions'};})
Truth table0%0/3
A && B
A= defined $p->{'function'}B= grep({$_ eq $p->{'function'};} @{$$pargs{'exclude_functions'};})
ABresult
0X0
100
111
587 0 } @{ $parsed->{participants} }];
588 }
589 0 ▶ if ($pargs->{include_function_pattern}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"include_function_pattern"}) 0 0 0
590 $parsed->{participants} = [grep {
591 0 my $p = $_;
592 0 ▶ defined($p->{function}) && $p->{function} =~ qr/$pargs->{include_function_pattern}/i
Condition0%0/3
defined $p->{'function'} && $p->{'function'} =~ qr/$pargs->{'include_function_pattern'}/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->{'function'} && $p->{'function'} =~ qr/$pargs->{'include_function_pattern'}/i
defined $p->{'function'} $p->{'function'} =~ qr/$pargs->{'include_function_pattern'}/i
Truth table0%0/3
A && B
A= defined $p->{'function'}B= $p->{'function'} =~ qr/$pargs->{'include_function_pattern'}/i
ABresult
0X0
100
111
593 0 } @{ $parsed->{participants} }];
594 }
595 0 ▶ if ($pargs->{exclude_function_pattern}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"exclude_function_pattern"}) 0 0 0
596 $parsed->{participants} = [grep {
597 0 my $p = $_;
598 0 ▶ !defined($p->{function}) || $p->{function} !~ qr/$pargs->{exclude_function_pattern}/i
Condition0%0/3
defined $p->{'function'} && $p->{'function'} =~ qr/$pargs->{'exclude_function_pattern'}/i
!ll&&!rl&&r
000
MC/DC0%0/2
defined $p->{'function'} && $p->{'function'} =~ qr/$pargs->{'exclude_function_pattern'}/i
defined $p->{'function'} $p->{'function'} =~ qr/$pargs->{'exclude_function_pattern'}/i
Truth table0%0/3
A && B
A= defined $p->{'function'}B= $p->{'function'} =~ qr/$pargs->{'exclude_function_pattern'}/i
ABresult
0X0
100
111
599 0 } @{ $parsed->{participants} }];
600 }
601  
602 0 ▶ if ($pargs->{exclude_pp_modules} || $pargs->{exclude_xs_modules}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"exclude_pp_modules"} or $pargs->{"exclude_xs_modules"}) 0 0 0
Condition0%0/3
$pargs->{"exclude_pp_modules"} or $pargs->{"exclude_xs_modules"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$pargs->{"exclude_pp_modules"} or $pargs->{"exclude_xs_modules"}
$pargs->{"exclude_pp_modules"} $pargs->{"exclude_xs_modules"}
Truth table0%0/3
A or B
A= $pargs->{"exclude_pp_modules"}B= $pargs->{"exclude_xs_modules"}
ABresult
1X1
011
000
603 0 require Module::XSOrPP;
604 $parsed->{participants} = [grep {
605 0 ▶ if (!defined($_->{module})) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_->{'module'}) { } 0 0 0
606 0 1;
607 } else {
608 0 my $xs_or_pp = Module::XSOrPP::xs_or_pp($_->{module});
609 0 ▶ if (!$xs_or_pp) {
Branch: 3 branches
BranchTrueFalseTotal
if (not $xs_or_pp) { } 0 0 0
elsif ($xs_or_pp =~ /xs/ and $pargs->{'exclude_xs_modules'}) { } 0 0 0
elsif ($xs_or_pp =~ /pp/ and $pargs->{'exclude_pp_modules'}) { } 0 0 0
610 0 warn "Can't determine if module '$_->{module}' is XS or PP";
611 0 1;
612 ▶ } elsif ($xs_or_pp =~ /xs/ && $pargs->{exclude_xs_modules}) {
Condition0%0/3
$xs_or_pp =~ /xs/ and $pargs->{"exclude_xs_modules"}
!ll&&!rl&&r
000
MC/DC0%0/2
$xs_or_pp =~ /xs/ and $pargs->{"exclude_xs_modules"}
$xs_or_pp =~ /xs/ $pargs->{"exclude_xs_modules"}
Truth table0%0/3
A and B
A= $xs_or_pp =~ /xs/B= $pargs->{"exclude_xs_modules"}
ABresult
0X0
100
111
613 0 log_info("Excluding XS module '$_->{module}'");
614 0 0;
615 ▶ } elsif ($xs_or_pp =~ /pp/ && $pargs->{exclude_pp_modules}) {
Condition0%0/3
$xs_or_pp =~ /pp/ and $pargs->{"exclude_pp_modules"}
!ll&&!rl&&r
000
MC/DC0%0/2
$xs_or_pp =~ /pp/ and $pargs->{"exclude_pp_modules"}
$xs_or_pp =~ /pp/ $pargs->{"exclude_pp_modules"}
Truth table0%0/3
A and B
A= $xs_or_pp =~ /pp/B= $pargs->{"exclude_pp_modules"}
ABresult
0X0
100
111
616 0 log_info("Excluding PP module '$_->{module}'");
617 0 0;
618 } else {
619 0 1;
620 }
621 }
622 0 } @{ $parsed->{participants} }];
623 }
624 }
625  
626 $parsed->{participants} = _filter_records(
627 entity => 'participant',
628 records => $parsed->{participants},
629 include => $pargs->{include_participants},
630 exclude => $pargs->{exclude_participants},
631 include_name => $pargs->{include_participant_names},
632 exclude_name => $pargs->{exclude_participant_names},
633 include_seq => $pargs->{include_participant_seqs},
634 exclude_seq => $pargs->{exclude_participant_seqs},
635 include_pattern => $pargs->{include_participant_pattern},
636 exclude_pattern => $pargs->{exclude_participant_pattern},
637 include_tags => $pargs->{include_participant_tags},
638 exclude_tags => $pargs->{exclude_participant_tags},
639 0 ▶ apply_include_by_default_filter => $aibdf,
Branch: 1 branch
BranchTrueFalseTotal
if $apply_filters 0 0 0
640 ) if $apply_filters;
641 } # normalize participants
642  
643 0 ▶ if ($parsed->{before_parse_datasets}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_parse_datasets"}) 0 0 0
644 0 log_info("Executing before_parse_datasets hook ...");
645 $parsed->{before_parse_datasets}->(
646 hook_name => 'before_parse_datasets',
647 scenario => $unparsed,
648 stash => $args{stash},
649 0 );
650 }
651  
652 # normalize datasets
653 0 ▶ if ($unparsed->{datasets}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unparsed->{"datasets"}) 0 0 0
654 0 $parsed->{datasets} = [];
655 0 my $i = -1;
656 0 my $dss0 = $unparsed->{datasets};
657  
658 0 my $td_args;
659 my @uniq_args;
660  
661 0 for my $ds0 (@$dss0) {
662 0 $i++;
663 0 my $ds = { %$ds0, seq=>$i };
664 0 ▶ $ds->{include_by_default} //= 1;
Condition0%0/2
$ds->{"include_by_default"} //= 1
l!l
00
MC/DC0%0/1
$ds->{"include_by_default"} //= 1
$ds->{"include_by_default"}
Truth table0%0/2
A
A= $ds->{"include_by_default"}
Aresult
11
00
665  
666 # try to come up with a nicer name for the dataset (not necessarily
667 # unique): extract from argument values
668 0 ▶ unless (defined($ds->{name})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $ds->{"name"}) 0 0 0
669 0 ▶ unless ($td_args) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($td_args) 0 0 0
670 0 ▶ if (all {$_->{args}} @$dss0) {
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if (&all(sub { $_->{'args'}; } , @$dss0)) { } 0 0 0
671 0 require Data::TableData::Object::aohos;
672 $td_args = Data::TableData::Object::aohos->new(
673 0 [map {$_->{args}} @$dss0]);
674 0 @uniq_args = $td_args->uniq_col_names;
675 } else {
676 0 $td_args = -1;
677 }
678 }
679 0 ▶ if (@uniq_args > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (@uniq_args > 1) { } 0 0 0
elsif (@uniq_args) { } 0 0 0
680 $ds->{name} = dmp(
681 0 { map {$_ => $ds->{args}{$_}} @uniq_args });
682 } elsif (@uniq_args) {
683 0 $ds->{name} = $ds->{args}{$uniq_args[0]};
684 0 ▶ $ds->{name} = dmp($ds->{name}) if ref($ds->{name});
Branch: 1 branch
BranchTrueFalseTotal
if ref $ds->{"name"} 0 0 0
685 }
686 }
687  
688  
689 0 push @{ $parsed->{datasets} }, $ds;
690 } # for each dataset
691  
692 $parsed->{datasets} = _filter_records(
693 entity => 'dataset',
694 records => $parsed->{datasets},
695 include => $pargs->{include_datasets},
696 exclude => $pargs->{exclude_datasets},
697 include_name => $pargs->{include_dataset_names},
698 exclude_name => $pargs->{exclude_dataset_names},
699 include_seq => $pargs->{include_dataset_seqs},
700 exclude_seq => $pargs->{exclude_dataset_seqs},
701 include_pattern => $pargs->{include_dataset_pattern},
702 exclude_pattern => $pargs->{exclude_dataset_pattern},
703 include_tags => $pargs->{include_dataset_tags},
704 exclude_tags => $pargs->{exclude_dataset_tags},
705 0 ▶ apply_include_by_default_filter => $aibdf,
Branch: 1 branch
BranchTrueFalseTotal
if $apply_filters 0 0 0
706 ) if $apply_filters;
707 } # normalize datasets
708  
709 0 $parsed;
710 }
711  
712 0 ▶sub _get_participant_modules {
Subroutine _get_participant_modules: not called CC=7 SCAR=40.3
713 0 my $parsed = shift;
714  
715 0 my @modules;
716 0 for my $p (@{ $parsed->{participants} }) {
717 0 ▶ if (defined $p->{module}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $p->{'module'}) { } 0 0 0
elsif (defined $p->{'modules'}) { } 0 0 0
718 0 ▶ push @modules, $p->{module} unless grep { $_ eq $p->{module} } @modules;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $p->{"module"};} @modules 0 0 0
719 } elsif (defined $p->{modules}) {
720 0 for my $m (@{ $p->{modules} }) {
721 0 ▶ push @modules, $m unless grep { $_ eq $m } @modules;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $m;} @modules 0 0 0
722 }
723 }
724 }
725  
726 0 @modules;
727 }
728  
729 0 ▶sub _get_participant_helper_modules {
Subroutine _get_participant_helper_modules: not called CC=5 SCAR=34.0
730 0 my $parsed = shift;
731  
732 0 my @modules;
733 0 for my $p (@{ $parsed->{participants} }) {
734 0 ▶ if (defined $p->{helper_modules}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p->{"helper_modules"}) 0 0 0
735 0 for my $m (@{ $p->{helper_modules} }) {
736 0 ▶ push @modules, $m unless grep { $_ eq $m } @modules;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $m;} @modules 0 0 0
737 }
738 }
739 }
740  
741 0 @modules;
742 }
743  
744 0 ▶sub _get_participant_functions {
Subroutine _get_participant_functions: not called CC=4 SCAR=30.0
745 0 my $parsed = shift;
746  
747 0 my @functions;
748 0 for my $p (@{ $parsed->{participants} }) {
749 0 ▶ next unless defined $p->{function};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $p->{"function"} 0 0 0
750 0 ▶ push @functions, $p->{function} unless grep { $_ eq $p->{function} } @functions;
Branch: 1 branch
BranchTrueFalseTotal
unless grep {$_ eq $p->{"function"};} @functions 0 0 0
751 }
752  
753 0 @functions;
754 }
755  
756 0 ▶sub _gen_items {
Subroutine _gen_items: not called CC=150 SCAR=100.3
757 0 require Permute::Named::Iter;
758  
759 0 my %args = @_;
760  
761 0 my $parsed = $args{scenario};
762 0 my $pargs = $args{parent_args};
763 0 ▶ my $apply_filters = $args{apply_filters} // 1;
Condition0%0/2
$args{"apply_filters"} // 1
l!l
00
MC/DC0%0/1
$args{"apply_filters"} // 1
$args{"apply_filters"}
Truth table0%0/2
A
A= $args{"apply_filters"}
Aresult
11
00
764  
765 0 $parsed->{items} = [];
766 0 my @permute;
767  
768 my $participants;
769 0 my $datasets;
770 0 my $env_hashes;
771 0 ▶ my $module_startup = $pargs->{module_startup} // $parsed->{module_startup};
Condition0%0/3
$pargs->{"module_startup"} // $parsed->{"module_startup"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$pargs->{"module_startup"} // $parsed->{"module_startup"}
$pargs->{"module_startup"} $parsed->{"module_startup"}
Truth table0%0/3
A // B
A= $pargs->{"module_startup"}B= $parsed->{"module_startup"}
ABresult
1X1
011
000
772 0 ▶ my $code_startup = $pargs->{code_startup} // $parsed->{code_startup};
Condition0%0/3
$pargs->{"code_startup"} // $parsed->{"code_startup"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$pargs->{"code_startup"} // $parsed->{"code_startup"}
$pargs->{"code_startup"} $parsed->{"code_startup"}
Truth table0%0/3
A // B
A= $pargs->{"code_startup"}B= $parsed->{"code_startup"}
ABresult
1X1
011
000
773  
774 0 my @modules = _get_participant_modules($parsed);
775  
776 0 ▶ if ($module_startup) {
Branch: 2 branches
BranchTrueFalseTotal
if ($module_startup) { } 0 0 0
elsif ($code_startup) { } 0 0 0
777 0 my %mem;
778 # push perl as base-line
779 0 push @$participants, {
780 seq => 0,
781 name => "perl -e1 (baseline)",
782 type => 'command',
783 perl_cmdline => ["-e1"],
784 };
785  
786 0 my $i = 0;
787 0 for my $p0 (@{ $parsed->{participants} }) {
788 0 my $key;
789 0 ▶ if (defined $p0->{module}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $p0->{'module'}) { } 0 0 0
elsif (defined $p0->{'modules'}) { } 0 0 0
790 0 $key = $p0->{module};
791 0 ▶ next if $mem{$key}++;
Branch: 1 branch
BranchTrueFalseTotal
if $mem{$key}++ 0 0 0
792 push @$participants, {
793 seq => ++$i,
794 name => $key,
795 type => 'command',
796 module => $p0->{module},
797 (import_args => $p0->{import_args}) x !!defined($p0->{import_args}),
798 0 perl_cmdline => [do {
799 0 my $mod = $p0->{module};
800 0 my $ia = $p0->{import_args};
801  
802 0 ▶ if (defined $ia && $ia eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ia and $ia eq '') { } 0 0 0
elsif (defined $ia) { } 0 0 0
Condition0%0/3
defined $ia and $ia eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ia and $ia eq ""
defined $ia $ia eq ""
Truth table0%0/3
A and B
A= defined $iaB= $ia eq ""
ABresult
0X0
100
111
803 0 "-m$mod";
804 } elsif (defined $ia) {
805 0 ▶ "-M$mod=".(ref($ia) eq 'ARRAY' ? join(",",@$ia) : $ia);
Branch: 1 branch
BranchTrueFalseTotal
ref $ia eq 'ARRAY' ? : 0 0 0
806 } else {
807 0 "-M$mod";
808 }
809 }, "-e1"],
810 };
811 } elsif (defined $p0->{modules}) {
812 0 $key = join("+", @{ $p0->{modules} });
813 0 ▶ next if $mem{$key}++;
Branch: 1 branch
BranchTrueFalseTotal
if $mem{$key}++ 0 0 0
814 push @$participants, {
815 seq => ++$i,
816 name => $key,
817 type => 'command',
818 modules => $p0->{modules},
819 (import_args_array => $p0->{import_args_array}) x !!defined($p0->{import_args_array}),
820 0 perl_cmdline => [do {
821 0 my @argv;
822 0 my $mods = $p0->{modules};
823 0 my $iaa = $p0->{import_args_array};
824 0 for my $i (0..$#{$mods}) {
825 0 my $mod = $mods->[$i];
826 0 ▶ my $ia = defined $iaa && defined $iaa->[$i] ? $iaa->[$i] : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $iaa && defined $iaa->[$i] ? : 0 0 0
Condition0%0/3
defined $iaa and defined $iaa->[$i]
!ll&&!rl&&r
000
MC/DC0%0/2
defined $iaa and defined $iaa->[$i]
defined $iaa defined $iaa->[$i]
Truth table0%0/3
A and B
A= defined $iaaB= defined $iaa->[$i]
ABresult
0X0
100
111
827 0 ▶ if (defined $ia && $ia eq '') {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $ia and $ia eq '') { } 0 0 0
elsif (defined $ia) { } 0 0 0
Condition0%0/3
defined $ia and $ia eq ""
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ia and $ia eq ""
defined $ia $ia eq ""
Truth table0%0/3
A and B
A= defined $iaB= $ia eq ""
ABresult
0X0
100
111
828 0 push @argv, "-m$mod";
829 } elsif (defined $ia) {
830 0 ▶ push @argv, "-M$mod=".(ref($ia) eq 'ARRAY' ? join(",",@$ia) : $ia);
Branch: 1 branch
BranchTrueFalseTotal
ref $ia eq 'ARRAY' ? : 0 0 0
831 } else {
832 0 push @argv, "-M$mod";
833 }
834 }
835 0 @argv;
836 }, "-e1"],
837 };
838 }
839 }
840 0 ▶ return [412, "There are no modules to benchmark ".
Branch: 1 branch
BranchTrueFalseTotal
unless %mem 0 0 0
841 "the startup overhead of"] unless %mem;
842 } elsif ($code_startup) {
843 0 push @$participants, {
844 seq => 0,
845 name => "perl -e1 (baseline)",
846 type => 'command',
847 perl_cmdline => ["-e1"],
848 };
849 0 my $i = 0;
850 0 for my $p0 (@{ $parsed->{participants} }) {
851 0 ▶ if ($p0->{type} ne 'perl_code') {
Branch: 1 branch
BranchTrueFalseTotal
if ($p0->{"type"} ne "perl_code") 0 0 0
852 0 log_info("Skipping participant #$p0->{seq}: type '$p0-{type}' not supported in code startup mode");
853 0 next;
854 }
855 0 ▶ if ($p0->{code}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p0->{"code"}) 0 0 0
856 0 log_info("Skipping participant #$p0->{seq}: raw 'code' not yet supported in code startup mode, use code_template instead");
857 0 next;
858 }
859 0 ▶ unless (defined $p0->{code_template} || defined $p0->{fcall_template}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $p0->{"code_template"} or defined $p0->{"fcall_template"}) 0 0 0
Condition0%0/3
defined $p0->{"code_template"} or defined $p0->{"fcall_template"}
l!l&&r!l&&!r
000
MC/DC0%0/2
defined $p0->{"code_template"} or defined $p0->{"fcall_template"}
defined $p0->{"code_template"} defined $p0->{"fcall_template"}
Truth table0%0/3
A or B
A= defined $p0->{"code_template"}B= defined $p0->{"fcall_template"}
ABresult
1X1
011
000
860 0 log_info("Skipping participant #$p0->{seq}: perl code needs to be in code_template/fcall_template");
861 0 next;
862 }
863 0 $i++;
864 push @$participants, {
865 seq => $i,
866 name => $p0->{name} // $p0->{_name},
867 type => 'command',
868 perl_cmdline_template => [
869 (defined $p0->{module} ? ("-M$p0->{module}") : ()),
870 0 ▶ (map { "-M$_" } @{ $p0->{modules} // [] }),
Condition0%0/2
$p0->{"modules"} // []
l!l
00
MC/DC0%0/1
$p0->{"modules"} // []
$p0->{"modules"}
Truth table0%0/2
A
A= $p0->{"modules"}
Aresult
11
00
871 0 ▶ (map { "-M$_" } @{ $p0->{helper_modules} // [] }),
Condition0%0/5
$p0->{"helper_modules"} // []
l!l
00
$p0->{"fcall_template"} // $p0->{"code_template"}
l!l&&r!l&&!r
000
MC/DC0%0/1
$p0->{"helper_modules"} // []
$p0->{"helper_modules"}
MC/DC0%0/2
$p0->{"fcall_template"} // $p0->{"code_template"}
$p0->{"fcall_template"} $p0->{"code_template"}
Truth table0%0/2
A
A= $p0->{"helper_modules"}
Aresult
11
00
Truth table0%0/3
A // B
A= $p0->{"fcall_template"}B= $p0->{"code_template"}
ABresult
1X1
011
000
872 0 ▶ '-e', ($p0->{fcall_template} // $p0->{code_template}),
Branch: 1 branch
BranchTrueFalseTotal
defined $p0->{'module'} ? : 0 0 0
Condition0%0/3
$p0->{"name"} // $p0->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$p0->{"name"} // $p0->{"_name"}
$p0->{"name"} $p0->{"_name"}
Truth table0%0/3
A // B
A= $p0->{"name"}B= $p0->{"_name"}
ABresult
1X1
011
000
873 ],
874 };
875 }
876 0 ▶ return [412, "There are no participants that can be benchmarked in ".
Branch: 1 branch
BranchTrueFalseTotal
unless $i 0 0 0
877 "code startup mode"] unless $i;
878 } else {
879 return [412, "Please load a scenario (-m, -f) or ".
880 "include at least one participant (-p)"]
881 0 ▶ unless @{$parsed->{participants}};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$parsed->{"participants"};} 0 0 0
882 0 $participants = $parsed->{participants};
883 0 ▶ $datasets = $parsed->{datasets} if $parsed->{datasets};
Branch: 1 branch
BranchTrueFalseTotal
if $parsed->{"datasets"} 0 0 0
884 }
885  
886 0 my %perl_exes; # key=name, val=path
887 {
888 0 my @perls;
889 0 ▶ if ($pargs->{multiperl}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{'multiperl'}) { } 0 0 0
890 0 require App::perlbrew;
891 0 @perls = grep {$_->{has_bencher}} _list_perls();
892 0 ▶ return [412, "Can't multiperl because no perl has Bencher installed"]
Branch: 1 branch
BranchTrueFalseTotal
unless @perls 0 0 0
893 unless @perls;
894  
895 0 ▶ if ($pargs->{include_perls} && @{ $pargs->{include_perls} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"include_perls"} and @{$pargs->{"include_perls"};}) 0 0 0
Condition0%0/3
$pargs->{"include_perls"} and @{$pargs->{"include_perls"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"include_perls"} and @{$pargs->{"include_perls"};}
$pargs->{"include_perls"} @{$pargs->{"include_perls"};}
Truth table0%0/3
A and B
A= $pargs->{"include_perls"}B= @{$pargs->{"include_perls"};}
ABresult
0X0
100
111
896 @perls = grep {
897 0 my $p = $_;
898 0 ▶ (grep { $p->{name} eq $_ } @{ $pargs->{include_perls} }) ? 1:0;
Branch: 1 branch
BranchTrueFalseTotal
grep({$p->{'name'} eq $_;} @{$$pargs{'include_perls'};}) ? : 0 0 0
899 } @perls;
900 }
901 0 ▶ if ($pargs->{exclude_perls} && @{ $pargs->{exclude_perls} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"exclude_perls"} and @{$pargs->{"exclude_perls"};}) 0 0 0
Condition0%0/3
$pargs->{"exclude_perls"} and @{$pargs->{"exclude_perls"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"exclude_perls"} and @{$pargs->{"exclude_perls"};}
$pargs->{"exclude_perls"} @{$pargs->{"exclude_perls"};}
Truth table0%0/3
A and B
A= $pargs->{"exclude_perls"}B= @{$pargs->{"exclude_perls"};}
ABresult
0X0
100
111
902 @perls = grep {
903 0 my $p = $_;
904 0 ▶ (grep { $p->{name} eq $_ } @{ $pargs->{exclude_perls} }) ? 0:1;
Branch: 1 branch
BranchTrueFalseTotal
grep({$p->{'name'} eq $_;} @{$$pargs{'exclude_perls'};}) ? : 0 0 0
905 } @perls;
906 }
907 0 ▶ die "You have to include at least one perl\n" unless @perls;
Branch: 1 branch
BranchTrueFalseTotal
unless @perls 0 0 0
908 0 for (@perls) {
909 0 $perl_exes{$_->{name}} = $_->{executable};
910 }
911 0 @perls = map {$_->{name}} @perls;
912 } else {
913 0 $perl_exes{perl} = $^X;
914 0 @perls = ("perl");
915 }
916 0 push @permute, "perl", \@perls;
917 }
918  
919 0 my %perl_opts; # key=name, val=[opt, ...]
920 0 ▶ if ($pargs->{multimodver}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"multimodver"}) 0 0 0
921 0 require ExtUtils::MakeMaker;
922 0 require Module::Path::More;
923  
924 0 local @INC = @INC;
925 0 ▶ if ($pargs->{include_path} && @{ $pargs->{include_path} }) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pargs->{"include_path"} and @{$pargs->{"include_path"};}) 0 0 0
Condition0%0/3
$pargs->{"include_path"} and @{$pargs->{"include_path"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$pargs->{"include_path"} and @{$pargs->{"include_path"};}
$pargs->{"include_path"} @{$pargs->{"include_path"};}
Truth table0%0/3
A and B
A= $pargs->{"include_path"}B= @{$pargs->{"include_path"};}
ABresult
0X0
100
111
926 0 unshift @INC, $_ for reverse @{ $pargs->{include_path} };
927 }
928  
929 0 my %versions; # key=module name
930 0 my $paths = Module::Path::More::module_path(module=>$pargs->{multimodver}, all=>1);
931  
932 0 ▶ if (@$paths < 1) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$paths < 1) 0 0 0
933 0 return [412, "Can't find module '$pargs->{multimodver}', try adding some --include-path"];
934 }
935 0 for my $path (@$paths) {
936 0 my $v = MM->parse_version($path);
937 0 ▶ $v = undef if defined($v) && $v eq 'undef';
Branch: 1 branch
BranchTrueFalseTotal
if defined $v and $v eq "undef" 0 0 0
Condition0%0/3
defined $v and $v eq "undef"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $v and $v eq "undef"
defined $v $v eq "undef"
Truth table0%0/3
A and B
A= defined $vB= $v eq "undef"
ABresult
0X0
100
111
938 0 ▶ if (!defined($v)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $v) 0 0 0
939 0 log_warn("Can't parse version from %s", $path);
940 0 next;
941 }
942 0 $versions{$v}++;
943 0 my $incdir = $path;
944 0 my $mod_pm = $pargs->{multimodver}; $mod_pm =~ s!::!/!g; $mod_pm .= ".pm";
945 0 $incdir =~ s!/\Q$mod_pm\E$!!;
946 0 ▶ $perl_opts{$v} //= ["-I$incdir"];
Condition0%0/2
$perl_opts{$v} //= ["-I$incdir"]
l!l
00
MC/DC0%0/1
$perl_opts{$v} //= ["-I$incdir"]
$perl_opts{$v}
Truth table0%0/2
A
A= $perl_opts{$v}
Aresult
11
00
947 }
948 0 ▶ return [412, "Can't find version number for module '$pargs->{multimodver}'"]
Branch: 1 branch
BranchTrueFalseTotal
unless keys %versions 0 0 0
949 unless keys(%versions);
950 0 push @permute, "modver", [keys %versions];
951 }
952  
953 0 push @permute, "participant", [map {$_->{seq}} @$participants];
954  
955 0 ▶ if ($datasets) {
Branch: 1 branch
BranchTrueFalseTotal
if ($datasets) 0 0 0
956 0 ▶ if (@$datasets) {
Branch: 1 branch
BranchTrueFalseTotal
if (@$datasets) { } 0 0 0
957 0 push @permute, "dataset", [map {$_->{seq}} @$datasets];
958 } else {
959 0 return [412, "Please include at least one dataset"];
960 }
961 }
962  
963 0 $env_hashes = $parsed->{env_hashes};
964 0 ▶ if ($env_hashes && @$env_hashes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($env_hashes and @$env_hashes) 0 0 0
Condition0%0/3
$env_hashes and @$env_hashes
!ll&&!rl&&r
000
MC/DC0%0/2
$env_hashes and @$env_hashes
$env_hashes @$env_hashes
Truth table0%0/3
A and B
A= $env_hashesB= @$env_hashes
ABresult
0X0
100
111
965 0 push @permute, "env_hash", [0..$#{$env_hashes}];
966 }
967  
968 0 log_debug("permute: %s", \@permute);
969  
970 # to store multiple argument values that are hash, e.g.
971 # {args=>{sizes=>{"1M"=>1024**2, "1G"=>1024**3, "1T"=>1024**4}}} instead of
972 # array: {args=>{sizes=>[1024**2, 1024**3, 1024**4]}}
973 0 my %ds_arg_values; # key=ds seq, val=hash(key=arg name, val=arg values)
974  
975 0 my $iter = Permute::Named::Iter::permute_named_iter(@permute);
976 0 my $item_seq = 0;
977 0 my $items = [];
978 0 my %item_mems; # key=item key, value=1
979 ITER:
980 0 ▶ while (my $h = $iter->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $h = &$iter()) 0 0 0
981 0 log_trace("iter returns: %s", $h);
982  
983 0 my $p = _find_record_by_seq($participants, $h->{participant});
984 0 my $ds;
985  
986 0 ▶ if (exists $h->{dataset}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $h->{"dataset"}) 0 0 0
987 0 $ds = _find_record_by_seq($datasets, $h->{dataset});
988 # filter first
989 0 ▶ if ($ds->{include_participant_tags}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ds->{"include_participant_tags"}) 0 0 0
990 0 my $included = 0;
991 INCTAG:
992 0 for my $tag (@{ $ds->{include_participant_tags} }) {
993 0 ▶ if ($tag =~ /\&/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /\&/) { } 0 0 0
994 0 for my $simpletag (split /\s*&\s*/, $tag) {
995 0 ▶ unless (grep {$simpletag eq $_} @{ $p->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$simpletag eq $_;} @{$p->{"tags"} // [];}) 0 0 0
Condition0%0/2
$p->{"tags"} // []
l!l
00
MC/DC0%0/1
$p->{"tags"} // []
$p->{"tags"}
Truth table0%0/2
A
A= $p->{"tags"}
Aresult
11
00
996 0 next INCTAG;
997 }
998 }
999 0 $included++;
1000 0 last INCTAG;
1001 } else {
1002 0 ▶ if (grep {$tag eq $_} @{ $p->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$tag eq $_;} @{$p->{"tags"} // [];}) 0 0 0
Condition0%0/2
$p->{"tags"} // []
l!l
00
MC/DC0%0/1
$p->{"tags"} // []
$p->{"tags"}
Truth table0%0/2
A
A= $p->{"tags"}
Aresult
11
00
1003 0 $included++;
1004 0 last INCTAG;
1005 }
1006 }
1007 }
1008 0 ▶ unless ($included) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($included) 0 0 0
1009 log_trace(
1010 "skipped dataset by include_participant_tags ".
1011 "(%s vs participant:%s)",
1012 0 $ds->{include_participant_tags}, $p->{tags});
1013 0 next ITER;
1014 }
1015 }
1016 0 ▶ if ($ds->{exclude_participant_tags}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ds->{"exclude_participant_tags"}) 0 0 0
1017 0 my $excluded = 0;
1018 EXCTAG:
1019 0 for my $tag (@{ $ds->{exclude_participant_tags} }) {
1020 0 ▶ if ($tag =~ /\&/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tag =~ /\&/) { } 0 0 0
1021 0 for my $simpletag (split /\s*&\s*/, $tag) {
1022 0 ▶ unless (grep {$simpletag eq $_} @{ $p->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$simpletag eq $_;} @{$p->{"tags"} // [];}) 0 0 0
Condition0%0/2
$p->{"tags"} // []
l!l
00
MC/DC0%0/1
$p->{"tags"} // []
$p->{"tags"}
Truth table0%0/2
A
A= $p->{"tags"}
Aresult
11
00
1023 0 next EXCTAG;
1024 }
1025 }
1026 0 $excluded++;
1027 0 last EXCTAG;
1028 } else {
1029 0 ▶ if (grep {$tag eq $_} @{ $p->{tags} // [] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$tag eq $_;} @{$p->{"tags"} // [];}) 0 0 0
Condition0%0/2
$p->{"tags"} // []
l!l
00
MC/DC0%0/1
$p->{"tags"} // []
$p->{"tags"}
Truth table0%0/2
A
A= $p->{"tags"}
Aresult
11
00
1030 0 $excluded++;
1031 0 last EXCTAG;
1032 }
1033 }
1034 }
1035 0 ▶ if ($excluded) {
Branch: 1 branch
BranchTrueFalseTotal
if ($excluded) 0 0 0
1036 log_trace(
1037 "skipped dataset by exclude_participant_tags ".
1038 "(%s vs participant:%s)",
1039 0 $ds->{exclude_participant_tags}, $p->{tags});
1040 0 next ITER;
1041 }
1042 }
1043 }
1044  
1045 0 my $iter_args;
1046 0 ▶ if ($ds && $ds->{args} &&
Branch: 1 branch
BranchTrueFalseTotal
if ($ds and $ds->{'args'} and my(@multi_keys) = grep({/\@\z/;} keys %{$$ds{'args'};})) { } 0 0 0
Condition0%0/6
$ds and $ds->{"args"} and my(@multi_keys) = grep({/\@\z/;} keys %{$$ds{"args"};})
!ll&&!rl&&r
000
$ds and $ds->{"args"}
!ll&&!rl&&r
000
MC/DC0%0/3
$ds and $ds->{"args"} and my(@multi_keys) = grep({/\@\z/;} keys %{$$ds{"args"};})
$ds $ds->{"args"} my(@multi_keys) = grep({/\@\z/;} keys %{$$ds{"args"};})
Truth table0%0/4
A and B and C
A= $dsB= $ds->{"args"}C= my(@multi_keys) = grep({/\@\z/;} keys %{$$ds{"args"};})
ABCresult
0XX0
10X0
1100
1111
1047 0 (my @multi_keys = grep {/\@\z/} keys %{$ds->{args}})) {
1048 # we need to permute arguments also
1049 0 my @permute_args;
1050 0 for my $mk0 (@multi_keys) {
1051 0 my $vals = $ds->{args}{$mk0};
1052 0 my $mk = $mk0; $mk =~ s/\@\z//;
1053 0 ▶ if (ref($vals) eq 'HASH') {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $vals eq 'HASH') { } 0 0 0
elsif (ref $vals eq 'ARRAY') { } 0 0 0
1054 0 push @permute_args, $mk => [sort keys %$vals];
1055 0 $ds_arg_values{$h->{dataset}}{$mk} = $vals;
1056 } elsif (ref($vals) eq 'ARRAY') {
1057 0 push @permute_args, $mk => $vals;
1058 } else {
1059 0 return [400, "Error in dataset #$h->{dataset} arg '$mk0': value must be hash or array"];
1060 }
1061 }
1062 0 $iter_args = Permute::Named::Iter::permute_named_iter(
1063 @permute_args);
1064 0 log_debug("permute args: %s", \@permute_args);
1065 } else {
1066 # create an iterator that returns just a single item: {}
1067 # require Array::Iter; $iter_args = Array::Iter::list_iter({});
1068 0 $iter_args = do {
1069 0 my $ary = [{}];
1070 0 my $i = 0;
1071 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1072 0 ▶ if ($i < @$ary) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$ary) { } 0 0 0
1073 0 return $ary->[$i++];
1074 } else {
1075 0 return undef;
1076 }
1077 0 };
1078 };
1079 }
1080  
1081 ITER_ARGS:
1082 0 ▶ while (my $h_args = $iter_args->()) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $h_args = &$iter_args()) 0 0 0
1083 0 my $args;
1084 0 ▶ if ($ds && $ds->{args}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ds and $ds->{"args"}) 0 0 0
Condition0%0/3
$ds and $ds->{"args"}
!ll&&!rl&&r
000
MC/DC0%0/2
$ds and $ds->{"args"}
$ds $ds->{"args"}
Truth table0%0/3
A and B
A= $dsB= $ds->{"args"}
ABresult
0X0
100
111
1085 0 $args = { %{$ds->{args}} };
1086 0 delete $args->{$_} for (grep {/\@\z/} keys %$args);
1087 0 for my $arg (keys %$h_args) {
1088 0 ▶ if ($ds_arg_values{$h->{dataset}}{$arg}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ds_arg_values{$h->{'dataset'}}{$arg}) { } 0 0 0
1089 0 $args->{$arg} = $ds_arg_values{$h->{dataset}}{$arg}{ $h_args->{$arg} };
1090 } else {
1091 0 $args->{$arg} = $h_args->{$arg};
1092 }
1093 }
1094 }
1095  
1096 0 my $code;
1097 my $code_str;
1098 0 my $template_vars;
1099 0 ▶ if ($p->{type} eq 'command') {
Branch: 2 branches
BranchTrueFalseTotal
if ($p->{'type'} eq 'command') { } 0 0 0
elsif ($p->{'type'} eq 'perl_code') { } 0 0 0
1100 0 require String::ShellQuote;
1101 0 my @cmd;
1102 my $shell;
1103 0 ▶ if (defined $p->{cmdline}) {
Branch: 4 branches
BranchTrueFalseTotal
if (defined $p->{'cmdline'}) { } 0 0 0
elsif (defined $p->{'perl_cmdline'}) { } 0 0 0
elsif (defined $p->{'cmdline_template'}) { } 0 0 0
elsif (defined $p->{'perl_cmdline_template'}) { } 0 0 0
1104 0 ▶ if (ref($p->{cmdline}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p->{'cmdline'} eq 'ARRAY') { } 0 0 0
1105 0 @cmd = @{ $p->{cmdline} };
1106 0 $shell = 0;
1107 } else {
1108 0 @cmd = ($p->{cmdline});
1109 0 $shell = 1;
1110 }
1111 } elsif (defined $p->{perl_cmdline}) {
1112 0 ▶ if (ref($p->{perl_cmdline}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p->{'perl_cmdline'} eq 'ARRAY') { } 0 0 0
1113 @cmd = ($perl_exes{$h->{perl}},
1114 0 ▶ ($h->{modver} ? @{$perl_opts{$h->{modver}} // []} : ()),
Condition0%0/2
$perl_opts{$h->{"modver"}} // []
l!l
00
MC/DC0%0/1
$perl_opts{$h->{"modver"}} // []
$perl_opts{$h->{"modver"}}
Truth table0%0/2
A
A= $perl_opts{$h->{"modver"}}
Aresult
11
00
1115 0 ▶ @{ $p->{perl_cmdline} });
Branch: 1 branch
BranchTrueFalseTotal
$h->{'modver'} ? : 0 0 0
1116 0 $shell = 0;
1117 } else {
1118 @cmd = (
1119 join(
1120 " ",
1121 $perl_exes{$h->{perl}},
1122 0 ▶ ($h->{modver} ? map {String::ShellQuote::shell_quote($_)} @{$perl_opts{$h->{modver}} // []} : ()),
Condition0%0/2
$perl_opts{$h->{"modver"}} // []
l!l
00
MC/DC0%0/1
$perl_opts{$h->{"modver"}} // []
$perl_opts{$h->{"modver"}}
Truth table0%0/2
A
A= $perl_opts{$h->{"modver"}}
Aresult
11
00
1123 $p->{perl_cmdline},
1124 )
1125 0 ▶ );
Branch: 1 branch
BranchTrueFalseTotal
$h->{'modver'} ? : 0 0 0
1126 0 $shell = 1;
1127 }
1128 } elsif (defined $p->{cmdline_template}) {
1129 0 ▶ if ($ds->{args}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ds->{'args'}) { } 0 0 0
elsif ($ds->{'argv'}) { } 0 0 0
1130 0 $template_vars = { %$args };
1131 } elsif ($ds->{argv}) {
1132 0 $template_vars = { map {$_=>$ds->{argv}[$_]}
1133 0 0..$#{ $ds->{argv} } };
1134 }
1135 0 ▶ if (ref($p->{cmdline_template}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p->{'cmdline_template'} eq 'ARRAY') { } 0 0 0
1136 0 @cmd = map { _fill_template($_, $template_vars) }
1137 0 @{ $p->{cmdline_template} };
1138 0 $shell = 0;
1139 } else {
1140 my $cmd = _fill_template(
1141 0 $p->{cmdline_template}, $template_vars, 'shell');
1142 0 @cmd = ($cmd);
1143 0 $shell = 1;
1144 }
1145 } elsif (defined $p->{perl_cmdline_template}) {
1146 0 ▶ if ($ds->{args}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ds->{'args'}) { } 0 0 0
elsif ($ds->{'argv'}) { } 0 0 0
1147 0 $template_vars = { %$args };
1148 } elsif ($ds->{argv}) {
1149 0 $template_vars = { map {$_=>$ds->{argv}[$_]}
1150 0 0..$#{ $ds->{argv} } };
1151 }
1152 0 ▶ if (ref($p->{perl_cmdline_template}) eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $p->{'perl_cmdline_template'} eq 'ARRAY') { } 0 0 0
1153 @cmd = (
1154 $perl_exes{$h->{perl}},
1155 0 ▶ ($h->{modver} ? @{$perl_opts{$h->{modver}} // []} : ()),
Condition0%0/2
$perl_opts{$h->{"modver"}} // []
l!l
00
MC/DC0%0/1
$perl_opts{$h->{"modver"}} // []
$perl_opts{$h->{"modver"}}
Truth table0%0/2
A
A= $perl_opts{$h->{"modver"}}
Aresult
11
00
1156 0 map { _fill_template($_, $template_vars) }
1157 0 ▶ @{ $p->{perl_cmdline_template} }
Branch: 1 branch
BranchTrueFalseTotal
$h->{'modver'} ? : 0 0 0
1158 );
1159 0 $shell = 0;
1160 } else {
1161 my $cmd = _fill_template(
1162 join(
1163 " ",
1164 $perl_exes{$h->{perl}},
1165 0 ▶ ($h->{modver} ? map {String::ShellQuote::shell_quote($_)} @{$perl_opts{$h->{modver}} // []} : ()),
Condition0%0/2
$perl_opts{$h->{"modver"}} // []
l!l
00
MC/DC0%0/1
$perl_opts{$h->{"modver"}} // []
$perl_opts{$h->{"modver"}}
Truth table0%0/2
A
A= $perl_opts{$h->{"modver"}}
Aresult
11
00
1166 $p->{perl_cmdline_template},
1167 0 ▶ ),
Branch: 1 branch
BranchTrueFalseTotal
$h->{'modver'} ? : 0 0 0
1168 $template_vars,
1169 'shell',
1170 );
1171 0 @cmd = ($cmd);
1172 0 $shell = 1;
1173 }
1174 } else {
1175 0 die "BUG: Unknown command type";
1176 }
1177  
1178 0 log_debug("Item #%d: cmdline=%s", $item_seq, \@cmd);
1179  
1180 {
1181 0 $code_str = "package main; sub { ";
1182 0 ▶ if (defined $h->{env_hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h->{"env_hash"}) 0 0 0
1183 0 my $env_hash = $env_hashes->[$h->{env_hash}];
1184 0 for (sort keys %$env_hash) {
1185 0 $code_str .= "local \$ENV{".dmp($_)."} = ".dmp($env_hash->{$_})."; ";
1186 }
1187 }
1188 0 ▶ if ($shell) {
Branch: 1 branch
BranchTrueFalseTotal
if ($shell) { } 0 0 0
1189 0 $code_str .= "system ".dmp($cmd[0])."; ";
1190 } else {
1191 0 $code_str .= "system {".dmp($cmd[0])."} \@{".dmp(\@cmd)."}; ";
1192 }
1193 0 $code_str .= q[die "Command failed (child error=$?, os error=$!)\\n" if $?];
1194 0 $code_str .= "}";
1195 0 $code = eval $code_str; ## no critic: BuiltinFunctions::ProhibitStringyEval
1196 0 ▶ die "BUG: Can't produce code for cmdline: $@ (code string is: $code_str)" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1197 };
1198 } elsif ($p->{type} eq 'perl_code') {
1199 0 ▶ if ($p->{code}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($p->{'code'}) { } 0 0 0
elsif (my $template = $p->{'code_template'} || $p->{'fcall_template'}) { } 0 0 0
1200 0 my $save_env;
1201 0 ▶ my $code_set_env = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1202 0 my $env_hash = $env_hashes->[shift];
1203 0 $save_env = {};
1204 0 for (keys %$env_hash) {
1205 0 $save_env->{$_} = $ENV{$_};
1206 0 $ENV{$_} = $env_hash->{$_};
1207 }
1208 0 };
1209 0 ▶ my $code_restore_env = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1210 0 for (keys %$save_env) {
1211 0 $ENV{$_} = $save_env->{$_};
1212 }
1213 0 };
1214 0 ▶ if ($ds) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ds) { } 0 0 0
1215 0 ▶ if ($ds->{argv}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ds->{'argv'}) { } 0 0 0
elsif ($ds->{'args'}) { } 0 0 0
1216 0 ▶ if (defined $h->{env_hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h->{'env_hash'}) { } 0 0 0
1217 0 ▶ $code = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1218 0 $code_set_env->($h->{env_hash});
1219 0 $p->{code}->(@{$ds->{argv}});
1220 0 $code_restore_env->();
1221 0 };
1222 } else {
1223 0 ▶ $code = sub { $p->{code}->(@{$ds->{argv}}) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
1224 }
1225 } elsif ($ds->{args}) {
1226 0 ▶ if (defined $h->{env_hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h->{'env_hash'}) { } 0 0 0
1227 0 ▶ $code = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1228 0 $code_set_env->($h->{env_hash});
1229 0 $p->{code}->(%$args);
1230 0 $code_restore_env->();
1231 0 };
1232 } else {
1233 0 ▶ $code = sub { $p->{code}->(%$args) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
1234 }
1235 } else {
1236 0 return [400, "Participant #$p->{seq}, dataset #$h->{dataset}: No argv/args supplied for code"];
1237 }
1238 } else {
1239 0 ▶ if (defined $h->{env_hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h->{'env_hash'}) { } 0 0 0
1240 0 ▶ $code = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1241 0 $code_set_env->($h->{env_hash});
1242 0 $p->{code}->();
1243 0 $code_restore_env->();
1244 0 };
1245 } else {
1246 0 $code = $p->{code};
1247 }
1248 }
1249 ▶ } elsif (my $template = $p->{code_template} || $p->{fcall_template}) {
Condition0%0/3
$p->{'code_template'} || $p->{'fcall_template'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$p->{'code_template'} || $p->{'fcall_template'}
$p->{'code_template'} $p->{'fcall_template'}
Truth table0%0/3
A || B
A= $p->{'code_template'}B= $p->{'fcall_template'}
ABresult
1X1
011
000
1250 0 ▶ if ($ds->{args}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($ds->{'args'}) { } 0 0 0
elsif ($ds->{'argv'}) { } 0 0 0
1251 0 $template_vars = { %$args };
1252 } elsif ($ds->{argv}) {
1253 0 $template_vars = { map {$_=>$ds->{argv}[$_]}
1254 0 0..$#{ $ds->{argv} } };
1255 } else {
1256 #warn "Item #$item_seq: participant specifies code_template/fcall_template but there is no args/argv in the dataset #$h->{dataset}\n";
1257 }
1258  
1259 0 $code_str = "package main; sub { ";
1260 0 ▶ if (defined $h->{env_hash}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $h->{"env_hash"}) 0 0 0
1261 0 my $env_hash = $env_hashes->[$h->{env_hash}];
1262 0 for (sort keys %$env_hash) {
1263 0 $code_str .= "local \$ENV{".dmp($_)."} = ".dmp($env_hash->{$_})."; ";
1264 }
1265 }
1266 0 $code_str .= _fill_template($template, $template_vars, 'dmp') . " }";
1267 0 log_debug("Item #%d: code=%s", $item_seq, $code_str);
1268 0 $code = eval $code_str; ## no critic: BuiltinFunctions::ProhibitStringyEval
1269 0 ▶ return [400, "Item #$item_seq: code compile error: $@ (code: $code_str)"] if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1270 }
1271 } else {
1272 0 return [400, "Unknown participant type '$p->{type}'"];
1273 }
1274  
1275 my $item = {
1276 (_code_str => $code_str ) x !!defined($code_str),
1277 _code => $code,
1278 _permute => $h,
1279 _template_vars => $template_vars,
1280 0 ((_permute_args => $h_args) x !!$ds->{args}),
1281 };
1282 0 ▶ $item->{p_tags} = join(", ", @{ $p->{tags} // [] });
Condition0%0/2
$p->{"tags"} // []
l!l
00
MC/DC0%0/1
$p->{"tags"} // []
$p->{"tags"}
Truth table0%0/2
A
A= $p->{"tags"}
Aresult
11
00
1283 0 ▶ $item->{ds_tags} = join(", ", @{ $ds->{tags} // [] }) if $ds;
Branch: 1 branch
BranchTrueFalseTotal
if $ds 0 0 0
Condition0%0/2
$ds->{"tags"} // []
l!l
00
MC/DC0%0/1
$ds->{"tags"} // []
$ds->{"tags"}
Truth table0%0/2
A
A= $ds->{"tags"}
Aresult
11
00
1284 0 for my $k (keys %$h) {
1285 0 ▶ if ($k eq 'perl') {
Branch: 5 branches
BranchTrueFalseTotal
if ($k eq 'perl') { } 0 0 0
elsif ($k eq 'modver') { } 0 0 0
elsif ($k eq 'dataset') { } 0 0 0
elsif ($k eq 'participant') { } 0 0 0
elsif ($k eq 'env_hash') { } 0 0 0
1286 0 $item->{perl} = $h->{$k};
1287 0 $item->{_perl_exe} = $perl_exes{ $h->{$k} };
1288 } elsif ($k eq 'modver') {
1289 0 $item->{modver} = $h->{$k};
1290 0 $item->{_perl_opts} = $perl_opts{ $h->{$k} };
1291 } elsif ($k eq 'dataset') {
1292 0 ▶ $item->{"dataset"} = $ds->{name} // "#$ds->{seq}";
Condition0%0/2
$ds->{"name"} // qq[#$ds->{"seq"}]
l!l
00
MC/DC0%0/1
$ds->{"name"} // qq[#$ds->{"seq"}]
$ds->{"name"}
Truth table0%0/2
A
A= $ds->{"name"}
Aresult
11
00
1293 } elsif ($k eq 'participant') {
1294 0 ▶ $item->{"participant"} = $p->{name} // $p->{_name} // "#$p->{seq}";
Condition0%0/5
($p->{"name"} // $p->{"_name"}) // qq[#$p->{"seq"}]
l!l
00
$p->{"name"} // $p->{"_name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($p->{"name"} // $p->{"_name"}) // qq[#$p->{"seq"}]
$p->{"name"} $p->{"_name"}
Truth table0%0/3
A // B
A= $p->{"name"}B= $p->{"_name"}
ABresult
1X1
011
000
1295 } elsif ($k eq 'env_hash') {
1296 0 $item->{env_hash} = $h->{$k};
1297 0 $item->{_env} = $env_hashes->[$h->{$k}];
1298 } else {
1299 0 $item->{"item_$k"} = $h->{$k};
1300 }
1301 }
1302 0 ▶ if ($ds->{args}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ds->{"args"}) 0 0 0
1303 0 for my $k (keys %$h_args) {
1304 0 $item->{"arg_$k"} = "$h_args->{$k}";
1305 }
1306 }
1307  
1308 # skip duplicate items
1309 0 my $key = dmp {map { $_ => $item->{$_} }
1310 0 grep { !/^_/ }
1311 sort keys %$item};
1312 0 log_trace("item key=%s", $key);
1313 0 ▶ if ($item_mems{$key}++) {
Branch: 1 branch
BranchTrueFalseTotal
if ($item_mems{$key}++) 0 0 0
1314 0 log_trace("Duplicate key, skipped item, recycling seq number %d", $item_seq);
1315 0 next ITER;
1316 }
1317  
1318 0 $item->{seq} = $item_seq++;
1319  
1320 0 push @$items, $item;
1321  
1322 0 ▶ last ITER_ARGS unless $ds->{args};
Branch: 1 branch
BranchTrueFalseTotal
unless $ds->{"args"} 0 0 0
1323 } # ITER_ARGS
1324  
1325 } # ITER
1326  
1327 0 _set_item_names($items);
1328  
1329 $items = _filter_records(
1330 entity => 'item',
1331 records => $items,
1332 include => $pargs->{include_items},
1333 exclude => $pargs->{exclude_items},
1334 include_name => $pargs->{include_item_names},
1335 exclude_name => $pargs->{exclude_item_names},
1336 include_seq => $pargs->{include_item_seqs},
1337 exclude_seq => $pargs->{exclude_item_seqs},
1338 include_pattern => $pargs->{include_item_pattern},
1339 exclude_pattern => $pargs->{exclude_item_pattern},
1340 0 ▶ ) if $apply_filters;
Branch: 1 branch
BranchTrueFalseTotal
if $apply_filters 0 0 0
1341  
1342 0 [200, "OK", $items, {'func.permute'=>\@permute}];
1343 }
1344  
1345 0 ▶sub _item_label {
Subroutine _item_label: not called CC=4 SCAR=30.0
1346 0 my %args = @_;
1347  
1348 0 my $item = $args{item};
1349 0 my $bencher_args = $args{bencher_args};
1350  
1351 join(
1352 "",
1353 "$item->{seq} ($item->{_name}",
1354 ($bencher_args->{multiperl} ? ", perl=$item->{perl}" : ""),
1355 ($bencher_args->{multimodver} ? ", modver=$item->{modver}" : ""),
1356 ($item->{_env} ?
1357 0 ", env={".join(" ", map {"$_=$item->{_env}{$_}"}
1358 0 ▶ sort keys %{$item->{_env}})."}" : ""),
Branch: 3 branches
BranchTrueFalseTotal
$bencher_args->{'multiperl'} ? : 0 0 0
$bencher_args->{'multimodver'} ? : 0 0 0
$item->{'_env'} ? : 0 0 0
1359 ")",
1360 );
1361 }
1362  
1363 0 ▶sub _complete_scenario_module {
Subroutine _complete_scenario_module: not called CC=5 SCAR=34.0
1364 0 my %args = @_;
1365 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1366 0 my $cmdline = $args{cmdline};
1367 0 my $r = $args{r};
1368  
1369 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1370  
1371 # force reading config file
1372 0 $r->{read_config} = 1;
1373 0 my $res = $cmdline->parse_argv($r);
1374 0 my $args = $res->[2];
1375  
1376 0 require Complete::Module;
1377 {
1378 0 local @INC = @INC;
1379 0 ▶ unshift @INC, $_ for @{ $args->{include_path} // [] };
Condition0%0/2
$args->{"include_path"} // []
l!l
00
MC/DC0%0/1
$args->{"include_path"} // []
$args->{"include_path"}
Truth table0%0/2
A
A= $args->{"include_path"}
Aresult
11
00
1380 Complete::Module::complete_module(
1381 0 word=>$args{word}, ns_prefix=>'Bencher::Scenario');
1382 }
1383 }
1384  
1385 0 ▶sub _complete_cpanmodules_module {
Subroutine _complete_cpanmodules_module: not called CC=5 SCAR=34.0
1386 0 my %args = @_;
1387 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1388 0 my $cmdline = $args{cmdline};
1389 0 my $r = $args{r};
1390  
1391 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1392  
1393 # force reading config file
1394 0 $r->{read_config} = 1;
1395 0 my $res = $cmdline->parse_argv($r);
1396 0 my $args = $res->[2];
1397  
1398 0 require Complete::Module;
1399 {
1400 0 local @INC = @INC;
1401 0 ▶ unshift @INC, $_ for @{ $args->{include_path} // [] };
Condition0%0/2
$args->{"include_path"} // []
l!l
00
MC/DC0%0/1
$args->{"include_path"} // []
$args->{"include_path"}
Truth table0%0/2
A
A= $args->{"include_path"}
Aresult
11
00
1402 Complete::Module::complete_module(
1403 0 word=>$args{word}, ns_prefix=>'Acme::CPANModules');
1404 }
1405 }
1406  
1407 0 ▶sub _complete_participant_module {
Subroutine _complete_participant_module: not called CC=3 SCAR=24.8
1408 0 my %args = @_;
1409 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1410 0 my $cmdline = $args{cmdline};
1411 0 my $r = $args{r};
1412  
1413 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1414  
1415 # force reading config file
1416 0 $r->{read_config} = 1;
1417 0 my $res = $cmdline->parse_argv($r);
1418  
1419 0 my $args = $res->[2];
1420 0 my $unparsed = _get_scenario(parent_args=>$args);
1421 my $parsed = _parse_scenario(
1422 scenario=>$unparsed,
1423 parent_args=>$args,
1424 apply_filters => $args{apply_filters},
1425 0 );
1426  
1427 0 my @modules = _get_participant_modules($parsed);
1428  
1429 0 require Complete::Util;
1430 0 Complete::Util::complete_array_elem(
1431 word => $word,
1432 array => \@modules,
1433 );
1434 }
1435  
1436 0 ▶sub _complete_participant_modules_comma_sep {
Subroutine _complete_participant_modules_comma_sep: not called CC=2 SCAR=17.9
1437 0 my %args = @_;
1438 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1439 0 my $cmdline = $args{cmdline};
1440 0 my $r = $args{r};
1441  
1442 0 my $all_pmods = _complete_participant_module(%args, word=>'', apply_filters=>0);
1443  
1444 # at this point Complete::Util is already loaded by _complete_participant_module
1445 0 Complete::Util::hashify_answer(
1446 Complete::Util::complete_comma_sep(
1447 word => $word,
1448 elems => $all_pmods,
1449 uniq => 1,
1450 ),
1451 {path_sep => ','},
1452 );
1453 }
1454  
1455 0 ▶sub _complete_function {
Subroutine _complete_function: not called CC=3 SCAR=24.8
1456 0 my %args = @_;
1457 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1458 0 my $cmdline = $args{cmdline};
1459 0 my $r = $args{r};
1460  
1461 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1462  
1463 # force reading config file
1464 0 $r->{read_config} = 1;
1465 0 my $res = $cmdline->parse_argv($r);
1466  
1467 0 my $args = $res->[2];
1468 0 my $unparsed = _get_scenario(parent_args=>$args);
1469 my $parsed = _parse_scenario(
1470 scenario=>$unparsed,
1471 parent_args=>$args,
1472 apply_filters => $args{apply_filters},
1473 0 );
1474  
1475 0 my @functions = _get_participant_functions($parsed);
1476  
1477 0 require Complete::Util;
1478 0 Complete::Util::complete_array_elem(
1479 word => $word,
1480 array => \@functions,
1481 );
1482 }
1483  
1484 0 ▶sub _complete_functions_comma_sep {
Subroutine _complete_functions_comma_sep: not called CC=2 SCAR=17.9
1485 0 my %args = @_;
1486 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1487 0 my $cmdline = $args{cmdline};
1488 0 my $r = $args{r};
1489  
1490 0 my $all_functions = _complete_function(%args, word=>'', apply_filters=>0);
1491  
1492 # at this point Complete::Util is already loaded by _complete_functions
1493 0 Complete::Util::hashify_answer(
1494 Complete::Util::complete_comma_sep(
1495 word => $word,
1496 elems => $all_functions,
1497 uniq => 1,
1498 ),
1499 {path_sep => ','},
1500 );
1501 }
1502  
1503 0 ▶sub _complete_participant {
Subroutine _complete_participant: not called CC=5 SCAR=34.0
1504 0 my %args = @_;
1505 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1506 0 my $cmdline = $args{cmdline};
1507 0 my $r = $args{r};
1508  
1509 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1510  
1511 # force reading config file
1512 0 $r->{read_config} = 1;
1513 0 my $res = $cmdline->parse_argv($r);
1514  
1515 0 my $args = $res->[2];
1516 0 my $unparsed = _get_scenario(parent_args=>$args);
1517 my $parsed = _parse_scenario(
1518 scenario=>$unparsed,
1519 parent_args=>$args,
1520 apply_filters => $args{apply_filters},
1521 0 );
1522  
1523 0 require Complete::Util;
1524 Complete::Util::complete_array_elem(
1525 word => $word,
1526 0 array => [grep {defined} map {(
1527 ($_->{seq} ) x !!($args{seq} || !defined($args{seq})),
1528 0 ▶ ($_->{name}, $_->{_name}) x !!($args{name} || !defined($args{name}))
Condition0%0/6
$args{'seq'} || !defined($args{'seq'})
l!l&&r!l&&!r
000
$args{'name'} || !defined($args{'name'})
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'seq'} || !defined($args{'seq'})
$args{'seq'} !defined($args{'seq'})
MC/DC0%0/2
$args{'name'} || !defined($args{'name'})
$args{'name'} !defined($args{'name'})
Truth table0%0/3
A || not(B)
A= $args{'seq'}B= !defined($args{'seq'})
ABresult
1X1
011
000
Truth table0%0/3
A || not(B)
A= $args{'name'}B= !defined($args{'name'})
ABresult
1X1
011
000
1529 0 )} @{$parsed->{participants}}],
1530 );
1531 }
1532  
1533 0 ▶sub _complete_participants_comma_sep {
Subroutine _complete_participants_comma_sep: not called CC=2 SCAR=17.9
1534 0 my %args = @_;
1535 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1536 0 my $cmdline = $args{cmdline};
1537 0 my $r = $args{r};
1538  
1539 0 my $all_participants = _complete_participant(%args, word=>'', apply_filters=>0);
1540  
1541 # at this point Complete::Util is already loaded by _complete_participant
1542 0 Complete::Util::hashify_answer(
1543 Complete::Util::complete_comma_sep(
1544 word => $word,
1545 elems => $all_participants,
1546 uniq => 1,
1547 ),
1548 {path_sep => ','},
1549 );
1550 }
1551  
1552 0 ▶sub _complete_participant_names_comma_sep {
Subroutine _complete_participant_names_comma_sep: not called CC=2 SCAR=17.9
1553 0 my %args = @_;
1554 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1555 0 my $cmdline = $args{cmdline};
1556 0 my $r = $args{r};
1557  
1558 0 my $all_pnames = _complete_participant(%args, word=>'', apply_filters=>0, seq=>0);
1559  
1560 # at this point Complete::Util is already loaded by _complete_participant
1561 0 Complete::Util::hashify_answer(
1562 Complete::Util::complete_comma_sep(
1563 word => $word,
1564 elems => $all_pnames,
1565 uniq => 1,
1566 ),
1567 {path_sep => ','},
1568 );
1569 }
1570  
1571 0 ▶sub _complete_participant_seqs_comma_sep {
Subroutine _complete_participant_seqs_comma_sep: not called CC=2 SCAR=17.9
1572 0 my %args = @_;
1573 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1574 0 my $cmdline = $args{cmdline};
1575 0 my $r = $args{r};
1576  
1577 0 my $all_pseqs = _complete_participant(%args, word=>'', apply_filters=>0, name=>0);
1578  
1579 # at this point Complete::Util is already loaded by _complete_participant
1580 0 Complete::Util::hashify_answer(
1581 Complete::Util::complete_comma_sep(
1582 word => $word,
1583 elems => $all_pseqs,
1584 uniq => 1,
1585 ),
1586 {path_sep => ','},
1587 );
1588 }
1589  
1590 0 ▶sub _complete_participant_tag {
Subroutine _complete_participant_tag: not called CC=6 SCAR=37.4
1591 0 my %args = @_;
1592 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1593 0 my $cmdline = $args{cmdline};
1594 0 my $r = $args{r};
1595  
1596 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1597  
1598 # force reading config file
1599 0 $r->{read_config} = 1;
1600 0 my $res = $cmdline->parse_argv($r);
1601  
1602 0 my $args = $res->[2];
1603 0 my $unparsed = _get_scenario(parent_args=>$args);
1604 my $parsed = _parse_scenario(
1605 scenario=>$unparsed,
1606 parent_args=>$args,
1607 apply_filters => $args{apply_filters},
1608 0 );
1609  
1610 0 my %tags;
1611 0 for my $p (@{ $parsed->{participants} }) {
1612 0 ▶ if ($p->{tags}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"tags"}) 0 0 0
1613 0 $tags{$_}++ for @{ $p->{tags} };
1614 }
1615 }
1616  
1617 0 require Complete::Util;
1618 0 Complete::Util::complete_array_elem(
1619 word => $word,
1620 array => [keys %tags],
1621 );
1622 }
1623  
1624 0 ▶sub _complete_participant_tags_comma_sep {
Subroutine _complete_participant_tags_comma_sep: not called CC=2 SCAR=17.9
1625 0 my %args = @_;
1626 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1627 0 my $cmdline = $args{cmdline};
1628 0 my $r = $args{r};
1629  
1630 0 my $all_tags = _complete_participant_tag(%args, word=>'', apply_filters=>0);
1631  
1632 # at this point Complete::Util is already loaded by _complete_participant
1633 0 Complete::Util::hashify_answer(
1634 Complete::Util::complete_comma_sep(
1635 word => $word,
1636 elems => $all_tags,
1637 uniq => 1,
1638 ),
1639 {path_sep => ','},
1640 );
1641 }
1642  
1643 0 ▶sub _complete_dataset {
Subroutine _complete_dataset: not called CC=5 SCAR=34.0
1644 0 my %args = @_;
1645 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1646 0 my $cmdline = $args{cmdline};
1647 0 my $r = $args{r};
1648  
1649 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1650  
1651 # force reading config file
1652 0 $r->{read_config} = 1;
1653 0 my $res = $cmdline->parse_argv($r);
1654  
1655 0 my $args = $res->[2];
1656 0 my $unparsed = _get_scenario(parent_args=>$args);
1657 my $parsed = _parse_scenario(
1658 scenario=>$unparsed,
1659 parent_args=>$args,
1660 apply_filters => $args{apply_filters},
1661 0 );
1662  
1663 0 require Complete::Util;
1664 Complete::Util::complete_array_elem(
1665 word => $word,
1666 0 array => [grep {defined} map {(
1667 ($_->{seq} ) x !!($args{seq} || !defined($args{seq})),
1668 0 ▶ ($_->{name}, $_->{_name}) x !!($args{name} || !defined($args{name})),
Condition0%0/6
$args{'seq'} || !defined($args{'seq'})
l!l&&r!l&&!r
000
$args{'name'} || !defined($args{'name'})
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'seq'} || !defined($args{'seq'})
$args{'seq'} !defined($args{'seq'})
MC/DC0%0/2
$args{'name'} || !defined($args{'name'})
$args{'name'} !defined($args{'name'})
Truth table0%0/3
A || not(B)
A= $args{'seq'}B= !defined($args{'seq'})
ABresult
1X1
011
000
Truth table0%0/3
A || not(B)
A= $args{'name'}B= !defined($args{'name'})
ABresult
1X1
011
000
1669 0 )} @{$parsed->{datasets}}],
1670 );
1671 }
1672  
1673 0 ▶sub _complete_datasets_comma_sep {
Subroutine _complete_datasets_comma_sep: not called CC=2 SCAR=17.9
1674 0 my %args = @_;
1675 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1676 0 my $cmdline = $args{cmdline};
1677 0 my $r = $args{r};
1678  
1679 0 my $all_datasets = _complete_dataset(%args, word=>'', apply_filters=>0);
1680  
1681 # at this point Complete::Util is already loaded by _complete_dataset
1682 0 Complete::Util::hashify_answer(
1683 Complete::Util::complete_comma_sep(
1684 word => $word,
1685 elems => $all_datasets,
1686 uniq => 1,
1687 ),
1688 {path_sep => ','},
1689 );
1690 }
1691  
1692 0 ▶sub _complete_dataset_names_comma_sep {
Subroutine _complete_dataset_names_comma_sep: not called CC=2 SCAR=17.9
1693 0 my %args = @_;
1694 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1695 0 my $cmdline = $args{cmdline};
1696 0 my $r = $args{r};
1697  
1698 0 my $all_dsnames = _complete_dataset(%args, word=>'', apply_filters=>0, seq=>0);
1699  
1700 # at this point Complete::Util is already loaded by _complete_dataset
1701 0 Complete::Util::hashify_answer(
1702 Complete::Util::complete_comma_sep(
1703 word => $word,
1704 elems => $all_dsnames,
1705 uniq => 1,
1706 ),
1707 {path_sep => ','},
1708 );
1709 }
1710  
1711 0 ▶sub _complete_dataset_seqs_comma_sep {
Subroutine _complete_dataset_seqs_comma_sep: not called CC=2 SCAR=17.9
1712 0 my %args = @_;
1713 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1714 0 my $cmdline = $args{cmdline};
1715 0 my $r = $args{r};
1716  
1717 0 my $all_dsseqs = _complete_dataset(%args, word=>'', apply_filters=>0, name=>0);
1718  
1719 # at this point Complete::Util is already loaded by _complete_dataset
1720 0 Complete::Util::hashify_answer(
1721 Complete::Util::complete_comma_sep(
1722 word => $word,
1723 elems => $all_dsseqs,
1724 uniq => 1,
1725 ),
1726 {path_sep => ','},
1727 );
1728 }
1729  
1730 0 ▶sub _complete_dataset_tag {
Subroutine _complete_dataset_tag: not called CC=6 SCAR=37.4
1731 0 my %args = @_;
1732 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1733 0 my $cmdline = $args{cmdline};
1734 0 my $r = $args{r};
1735  
1736 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1737  
1738 # force reading config file
1739 0 $r->{read_config} = 1;
1740 0 my $res = $cmdline->parse_argv($r);
1741  
1742 0 my $args = $res->[2];
1743 0 my $unparsed = _get_scenario(parent_args=>$args);
1744 my $parsed = _parse_scenario(
1745 scenario=>$unparsed,
1746 parent_args=>$args,
1747 apply_filters => $args{apply_filters},
1748 0 );
1749  
1750 0 my %tags;
1751 0 for my $p (@{ $parsed->{datasets} }) {
1752 0 ▶ if ($p->{tags}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"tags"}) 0 0 0
1753 0 $tags{$_}++ for @{ $p->{tags} };
1754 }
1755 }
1756  
1757 0 require Complete::Util;
1758 0 Complete::Util::complete_array_elem(
1759 word => $word,
1760 array => [keys %tags],
1761 );
1762 }
1763  
1764 0 ▶sub _complete_dataset_tags_comma_sep {
Subroutine _complete_dataset_tags_comma_sep: not called CC=2 SCAR=17.9
1765 0 my %args = @_;
1766 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1767 0 my $cmdline = $args{cmdline};
1768 0 my $r = $args{r};
1769  
1770 0 my $all_tags = _complete_dataset_tag(%args, word=>'', apply_filters=>0);
1771  
1772 # at this point Complete::Util is already loaded by _complete_participant
1773 0 Complete::Util::hashify_answer(
1774 Complete::Util::complete_comma_sep(
1775 word => $word,
1776 elems => $all_tags,
1777 uniq => 1,
1778 ),
1779 {path_sep => ','},
1780 );
1781 }
1782  
1783 0 ▶sub _complete_item {
Subroutine _complete_item: not called CC=6 SCAR=37.4
1784 0 my %args = @_;
1785 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1786 0 my $cmdline = $args{cmdline};
1787 0 my $r = $args{r};
1788  
1789 0 ▶ return undef unless $cmdline;
Branch: 1 branch
BranchTrueFalseTotal
unless $cmdline 0 0 0
1790  
1791 # force reading config file
1792 0 $r->{read_config} = 1;
1793 0 my $res = $cmdline->parse_argv($r);
1794  
1795 0 my $args = $res->[2];
1796 0 my $unparsed = _get_scenario(parent_args=>$args);
1797 my $parsed = _parse_scenario(
1798 scenario=>$unparsed,
1799 parent_args=>$args,
1800 apply_filters => $args{apply_filters},
1801 0 );
1802 $res = _gen_items(
1803 scenario=>$parsed,
1804 parent_args=>$args,
1805 apply_filters => $args{apply_filters},
1806 0 );
1807 0 ▶ return undef unless $res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->[0] == 200 0 0 0
1808 0 my $items = $res->[2];
1809  
1810 0 require Complete::Util;
1811 Complete::Util::complete_array_elem(
1812 word => $word,
1813 0 array => [grep {defined} map {(
1814 ($_->{seq} ) x !!($args{seq} || !defined($args{seq})),
1815 0 ▶ ($_->{name}, $_->{_name}) x !!($args{name} || !defined($args{name}))
Condition0%0/6
$args{'seq'} || !defined($args{'seq'})
l!l&&r!l&&!r
000
$args{'name'} || !defined($args{'name'})
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{'seq'} || !defined($args{'seq'})
$args{'seq'} !defined($args{'seq'})
MC/DC0%0/2
$args{'name'} || !defined($args{'name'})
$args{'name'} !defined($args{'name'})
Truth table0%0/3
A || not(B)
A= $args{'seq'}B= !defined($args{'seq'})
ABresult
1X1
011
000
Truth table0%0/3
A || not(B)
A= $args{'name'}B= !defined($args{'name'})
ABresult
1X1
011
000
1816 )} @$items],
1817 );
1818 }
1819  
1820 0 ▶sub _complete_items_comma_sep {
Subroutine _complete_items_comma_sep: not called CC=2 SCAR=17.9
1821 0 my %args = @_;
1822 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1823 0 my $cmdline = $args{cmdline};
1824 0 my $r = $args{r};
1825  
1826 0 my $all_items = _complete_items(%args, word=>'', apply_filters=>0);
1827  
1828 # at this point Complete::Util is already loaded by _complete_dataset
1829 0 Complete::Util::hashify_answer(
1830 Complete::Util::complete_comma_sep(
1831 word => $word,
1832 elems => $all_items,
1833 uniq => 1,
1834 ),
1835 {path_sep => ','},
1836 );
1837 }
1838  
1839 0 ▶sub _complete_item_names_comma_sep {
Subroutine _complete_item_names_comma_sep: not called CC=2 SCAR=17.9
1840 0 my %args = @_;
1841 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1842 0 my $cmdline = $args{cmdline};
1843 0 my $r = $args{r};
1844  
1845 0 my $all_inames = _complete_item(%args, word=>'', apply_filters=>0, seq=>0);
1846  
1847 # at this point Complete::Util is already loaded by _complete_item
1848 0 Complete::Util::hashify_answer(
1849 Complete::Util::complete_comma_sep(
1850 word => $word,
1851 elems => $all_inames,
1852 uniq => 1,
1853 ),
1854 {path_sep => ','},
1855 );
1856 }
1857  
1858 0 ▶sub _complete_item_seqs_comma_sep {
Subroutine _complete_item_seqs_comma_sep: not called CC=2 SCAR=17.9
1859 0 my %args = @_;
1860 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1861 0 my $cmdline = $args{cmdline};
1862 0 my $r = $args{r};
1863  
1864 0 my $all_iseqs = _complete_item(%args, word=>'', apply_filters=>0, name=>0);
1865  
1866 # at this point Complete::Util is already loaded by _complete_item
1867 0 Complete::Util::hashify_answer(
1868 Complete::Util::complete_comma_sep(
1869 word => $word,
1870 elems => $all_iseqs,
1871 uniq => 1,
1872 ),
1873 {path_sep => ','},
1874 );
1875 }
1876  
1877 # list installed perls, and check each perl if Bencher::Backend is installed
1878 0 ▶sub _list_perls {
Subroutine _list_perls: not called CC=5 SCAR=34.0
1879 0 require Capture::Tiny;
1880  
1881 0 eval { require App::perlbrew; 1 };
1882 0 ▶ return undef if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
1883  
1884 0 my $pb = App::perlbrew->new;
1885 0 my @perls = $pb->installed_perls;
1886 0 for my $perl (@perls) {
1887 my @cmd = (
1888 $perl->{executable},
1889 0 "-MBencher::Backend",
1890 "-e'print \$Bencher::Backend::VERSION'",
1891 );
1892 my ($stdout, $stderr, @res) =
1893 0 ▶ &Capture::Tiny::capture(sub { system @cmd });
Subroutine __ANON__: not called CC=1 SCAR=6.9
1894 0 ▶ if ($stderr || $?) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stderr or $?) { } 0 0 0
Condition0%0/3
$stderr or $?
l!l&&r!l&&!r
000
MC/DC0%0/2
$stderr or $?
$stderr $?
Truth table0%0/3
A or B
A= $stderrB= $?
ABresult
1X1
011
000
1895 0 $perl->{has_bencher} = 0;
1896 0 $perl->{bencher_version} = undef;
1897 } else {
1898 0 $perl->{has_bencher} = 1;
1899 0 $perl->{bencher_version} = $stdout;
1900 }
1901 }
1902  
1903 0 @perls;
1904 }
1905  
1906 0 ▶sub _complete_perl {
Subroutine _complete_perl: not called CC=2 SCAR=13.4
1907 3 ▶ no warnings 'once';
Subroutine BEGIN: called CC=1 SCAR=0.0
1908 0 require Complete::Util;
1909  
1910 0 my %args = @_;
1911 0 ▶ my $word = $args{word} // '';
Condition0%0/2
$args{"word"} // ""
l!l
00
MC/DC0%0/1
$args{"word"} // ""
$args{"word"}
Truth table0%0/2
A
A= $args{"word"}
Aresult
11
00
1912  
1913 0 my @perls = _list_perls();
1914  
1915 0 local $Complete::Common::OPT_FUZZY = 0;
1916 Complete::Util::complete_array_elem(
1917 word => $word,
1918 0 array => [map {$_->{name}} grep {$_->{has_bencher}} @perls],
1919 );
1920 }
1921  
1922 0 ▶sub _digest {
Subroutine _digest: not called CC=3 SCAR=24.8
1923 0 require File::Digest;
1924 0 my $path = shift;
1925 0 my $digests = {};
1926 0 for my $algo (qw/md5 sha1 sha256/) {
1927 0 my $res = File::Digest::digest_file(file => $path, algorithm=>$algo);
1928 0 ▶ next unless $res->[0] == 200;
Branch: 1 branch
BranchTrueFalseTotal
unless $res->[0] == 200 0 0 0
1929 0 $digests->{$algo} = $res->[2];
1930 }
1931 0 $digests;
1932 }
1933  
1934  
1935 # give each item a convenient name, which is a short combination of its
1936 # permutation (unnecessarily unique, just as a human-readable name)
1937 0 ▶sub _set_item_names {
Subroutine _set_item_names: not called CC=11 SCAR=48.8
1938 0 my $items = shift;
1939  
1940 0 ▶ return unless @$items;
Branch: 1 branch
BranchTrueFalseTotal
unless @$items 0 0 0
1941  
1942 0 require Data::TableData::Object::aohos;
1943 0 my $td = Data::TableData::Object::aohos->new($items);
1944 0 my @const_cols = $td->const_col_names;
1945  
1946 0 my @name_keys;
1947 0 for my $k (sort keys %{$items->[0]}) {
1948 0 ▶ next unless $k =~ /^(participant|p_.+|dataset|ds_.+|item_.+|arg_.+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $k =~ /^(participant|p_.+|dataset|ds_.+|item_.+|arg_.+)$/ 0 0 0
1949 0 ▶ next if grep {$k eq $_} @const_cols;
Branch: 1 branch
BranchTrueFalseTotal
if grep {$k eq $_;} @const_cols 0 0 0
1950 0 push @name_keys, $k;
1951 }
1952  
1953 0 require Sort::BySpec;
1954 0 my $sorter = Sort::BySpec::sort_by_spec(spec=>['participant', qr/^p_/, 'dataset', qr/^ds_/, qr/^item_/, qr/^arg_/]);
1955 0 my @sorted_name_keys = $sorter->(@name_keys);
1956  
1957 0 my $succinct_participant_names;
1958 0 ▶ if (grep { $_ eq 'participant' } @name_keys) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ eq "participant";} @name_keys) 0 0 0
1959 0 ▶ $succinct_participant_names = _compact_participant_names({req_uniq => @name_keys == 1 ? 1:0}, map { $_->{participant} } @$items);
Branch: 1 branch
BranchTrueFalseTotal
@name_keys == 1 ? : 0 0 0
1960 }
1961  
1962 0 for my $it (@$items) {
1963 0 ▶ $it->{_name} = join(" ", map {"$_=".($it->{$_} // "(undef)")}
Condition0%0/2
$it->{$_} // "(undef)"
l!l
00
MC/DC0%0/1
$it->{$_} // "(undef)"
$it->{$_}
Truth table0%0/2
A
A= $it->{$_}
Aresult
11
00
1964 @name_keys);
1965 # _succinct_name is for e.g. showing Benchmark.pm result where the
1966 # items' names are all shown together horizontally as columns, so
1967 # the names need to be shorter to avoid being visually overwhelming
1968 0 ▶ $it->{_succinct_name} = join(" ", map {($_ eq 'participant' ? $succinct_participant_names->{ $it->{$_} } : ($it->{$_} // "(undef)"))}
Branch: 1 branch
BranchTrueFalseTotal
$_ eq 'participant' ? : 0 0 0
Condition0%0/2
$it->{$_} // "(undef)"
l!l
00
MC/DC0%0/1
$it->{$_} // "(undef)"
$it->{$_}
Truth table0%0/2
A
A= $it->{$_}
Aresult
11
00
1969 @sorted_name_keys);
1970 }
1971 }
1972  
1973 0 ▶sub _compact_participant_names {
Subroutine _compact_participant_names: not called CC=13 SCAR=52.0
1974 0 require List::Util;
1975 0 require List::Util::Uniq;
1976  
1977 0 my ($opts, @names) = @_;
1978  
1979 0 my %res;
1980 0 ▶ goto UNCOMPACTED_RESULT if (List::Util::max(map { length } @names) // 0) <= 12;
Branch: 1 branch
BranchTrueFalseTotal
if (&List::Util::max(map({length $_;} @names)) // 0) <= 12 0 0 0
Condition0%0/2
&List::Util::max(map({length $_;} @names)) // 0
l!l
00
MC/DC0%0/1
&List::Util::max(map({length $_;} @names)) // 0
&List::Util::max(map({length $_;} @names))
Truth table0%0/2
A
A= &List::Util::max(map({length $_;} @names))
Aresult
11
00
1981  
1982 # assume Foo::Bar::baz form to be (module + func). otherwise we assume the
1983 # whole name is func.
1984 0 my (@prefixes, @funcs);
1985 0 for my $name (@names) {
1986 0 ▶ if ($name =~ /\A((?:\w+::)*)(\w+)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name =~ /\A((?:\w+::)*)(\w+)\z/) { } 0 0 0
1987 0 push @prefixes, $1;
1988 0 push @funcs, $2;
1989 } else {
1990 0 push @prefixes, '';
1991 0 push @funcs, $name;
1992 }
1993 }
1994  
1995 0 ▶ if (List::Util::Uniq::is_monovalued(@prefixes)) {
Branch: 1 branch
BranchTrueFalseTotal
if (List::Util::Uniq::is_monovalued(@prefixes)) { } 0 0 0
1996 0 @prefixes = (('') x @prefixes);
1997 0 ▶ goto FORM_RESULT if List::Util::max(map {length} @funcs) <= 12;
Branch: 1 branch
BranchTrueFalseTotal
if &List::Util::max(map({length $_;} @funcs)) <= 12 0 0 0
1998 } else {
1999 # XXX find unique parts, e.g. Foo::Bar & Foo::Baz -> FBr & FBz or
2000 # something like this. currently we return FB & FB.
2001 0 for (@prefixes) {
2002 0 s/(.)[^:]*::/$1/g;
2003 0 ▶ $_ = "$_:" if length;
Branch: 1 branch
BranchTrueFalseTotal
if length $_ 0 0 0
2004 }
2005 }
2006  
2007 # XXX find unique parts, e.g. foo_bar & foo_baz -> f_bar, f_baz. currently
2008 # we return f_b.
2009 0 for (@funcs) {
2010 0 ▶ next if / /; # probably not a function name, don't compact
Branch: 1 branch
BranchTrueFalseTotal
if / / 0 0 0
2011 0 s/(\S)\S*?(_|\z)/$1$2/g;
2012 }
2013  
2014 FORM_RESULT:
2015 0 my @new_names = map { $prefixes[$_] . $funcs[$_] } 0..$#names;
2016 0 ▶ if ($opts->{req_uniq}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opts->{"req_uniq"}) 0 0 0
2017 0 ▶ goto UNCOMPACTED_RESULT unless List::Util::Uniq::is_uniq(@new_names);
Branch: 1 branch
BranchTrueFalseTotal
unless List::Util::Uniq::is_uniq(@new_names) 0 0 0
2018 }
2019 0 %res = map { $names[$_] => $new_names[$_] } 0 .. $#names;
2020 0 goto RETURN_RESULT;
2021  
2022 UNCOMPACTED_RESULT:
2023 0 %res = map {$_=>$_} @names;
2024 0 goto RETURN_RESULT;
2025  
2026 0 RETURN_RESULT:
2027 return \%res;
2028 }
2029  
2030 my $_alias_spec_add_participant = {
2031 summary => 'Add a participant',
2032 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
2033 0 require JSON::MaybeXS;
2034  
2035 0 my $args = shift;
2036 0 push @{ $args->{participants} },
2037 JSON::MaybeXS::decode_json($_[0]);
2038 },
2039 3 };
2040  
2041 my $_alias_spec_add_dataset = {
2042 summary => 'Add a dataset',
2043 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
2044 0 require JSON::MaybeXS;
2045  
2046 0 my $args = shift;
2047 0 push @{ $args->{datasets} },
2048 JSON::MaybeXS::decode_json($_[0]);
2049 },
2050 3 };
2051  
2052 my $_alias_spec_add_env_hash = {
2053 summary => 'Add an environment hash',
2054 0 ▶ code => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
2055 0 require JSON::MaybeXS;
2056  
2057 0 my $args = shift;
2058 0 push @{ $args->{env_hashes} },
2059 JSON::MaybeXS::decode_json($_[0]);
2060 },
2061 3 };
2062  
2063 $SPEC{format_result} = {
2064 3 v => 1.1,
2065 summary => 'Format bencher result',
2066 args => {
2067 envres => {
2068 summary => 'Enveloped result from bencher',
2069 schema => 'array*', # XXX envres
2070 req => 1,
2071 pos => 0,
2072 },
2073 formatters => {
2074 'x.name.is_plural' => 1,
2075 'x.name.singular' => 'formatter',
2076 summary => 'Formatters specification',
2077 schema => ['array*', of=>[
2078 'any*', of=>[
2079 'str*',
2080 ['array*', len=>2, elems=>['str*', 'hash*']],
2081 ]
2082 ]],
2083 req => 1,
2084 pos => 1,
2085 },
2086 options => {
2087 'x.name.is_plural' => 1,
2088 'x.name.singular' => 'option',
2089 schema => 'hash*',
2090 pos => 2,
2091 },
2092 exclude_formatters => {
2093 'x.name.is_plural' => 1,
2094 'x.name.singular' => 'exclude_formatter',
2095 summary => 'Exclude Formatters specification',
2096 schema => ['array*', of=>'str*'],
2097 pos => 3,
2098 },
2099 },
2100 args_as => 'array',
2101 };
2102 0 ▶sub format_result {
Subroutine format_result: not called CC=14 SCAR=53.5
Pod documented
2103 0 require POSIX;
2104  
2105 0 my ($envres, $formatters, $opts) = @_;
2106  
2107 0 ▶ $opts //= {};
Condition0%0/2
$opts //= {}
l!l
00
MC/DC0%0/1
$opts //= {}
$opts
Truth table0%0/2
A
A= $opts
Aresult
11
00
2108 # XXX exclusive choices
2109 0 ▶ $opts->{render_as_benchmark_pm} //= 0;
Condition0%0/2
$opts->{"render_as_benchmark_pm"} //= 0
l!l
00
MC/DC0%0/1
$opts->{"render_as_benchmark_pm"} //= 0
$opts->{"render_as_benchmark_pm"}
Truth table0%0/2
A
A= $opts->{"render_as_benchmark_pm"}
Aresult
11
00
2110 0 ▶ $opts->{render_as_text_table} //= $opts->{render_as_benchmark_pm} ? 0:1;
Branch: 1 branch
BranchTrueFalseTotal
$opts->{'render_as_benchmark_pm'} ? : 0 0 0
Condition0%0/2
$opts->{"render_as_text_table"} //= $opts->{"render_as_benchmark_pm"} ? 0 : 1
l!l
00
MC/DC0%0/1
$opts->{"render_as_text_table"} //= $opts->{"render_as_benchmark_pm"} ? 0 : 1
$opts->{"render_as_text_table"}
Truth table0%0/2
A
A= $opts->{"render_as_text_table"}
Aresult
11
00
2111  
2112 $formatters //= [
2113 'AddComparisonFields',
2114 'ShowEnv',
2115 ['Sort', {by=>$opts->{sort}}],
2116 'ScaleTime',
2117 'ScaleRate',
2118 'ScaleSize',
2119 ['RoundNumbers', {scientific_notation => $opts->{scientific_notation}}],
2120 ($envres->[3]{'func.module_startup'} ? ('ModuleStartup') : ()),
2121 ($envres->[3]{'func.code_startup'} ? ('CodeStartup') : ()),
2122 'DeleteConstantFields',
2123 'DeleteNotesFieldIfEmpty',
2124 'DeleteSeqField',
2125  
2126 ('RenderAsTextTable') x !!$opts->{render_as_text_table},
2127 ('RenderAsBenchmarkPm') x !!$opts->{render_as_benchmark_pm},
2128 0 ▶ ];
Branch: 2 branches
BranchTrueFalseTotal
$envres->[3]{'func.module_startup'} ? : 0 0 0
$envres->[3]{'func.code_startup'} ? : 0 0 0
Condition0%0/2
$formatters //= ["AddComparisonFields", "ShowEnv", ["Sort", {"by", $opts->{"sort"}}], "ScaleTime", "ScaleRate", "ScaleSize", ["RoundNumbers", {"scientific_notation", $opts->{"scientific_notation"}}], $envres->[3]{"func.module_startup"} ? "ModuleStartup" : (), $envres->[3]{"func.code_startup"} ? "CodeStartup" : (), "DeleteConstantFields", "DeleteNotesFieldIfEmpty", "DeleteSeqField", ("RenderAsTextTable") x !!$opts->{"render_as_text_table"}, ("RenderAsBenchmarkPm") x !!$opts->{"render_as_benchmark_pm"}]
l!l
00
MC/DC0%0/1
$formatters //= ["AddComparisonFields", "ShowEnv", ["Sort", {"by", $opts->{"sort"}}], "ScaleTime", "ScaleRate", "ScaleSize", ["RoundNumbers", {"scientific_notation", $opts->{"scientific_notation"}}], $envres->[3]{"func.module_startup"} ? "ModuleStartup" : (), $envres->[3]{"func.code_startup"} ? "CodeStartup" : (), "DeleteConstantFields", "DeleteNotesFieldIfEmpty", "DeleteSeqField", ("RenderAsTextTable") x !!$opts->{"render_as_text_table"}, ("RenderAsBenchmarkPm") x !!$opts->{"render_as_benchmark_pm"}]
$formatters
Truth table0%0/2
A
A= $formatters
Aresult
11
00
2129  
2130 # load all formatter modules
2131 0 my @fmtobjs;
2132 0 for my $fmt (@$formatters) {
2133 0 my ($fmtname, $fmtargs);
2134 0 ▶ if (ref($fmt)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $fmt) { } 0 0 0
2135 0 $fmtname = $fmt->[0];
2136 0 $fmtargs = $fmt->[1];
2137 } else {
2138 0 $fmtname = $fmt;
2139 0 $fmtargs = {};
2140 }
2141 0 my $fmtmod = "Bencher::Formatter::$fmtname";
2142 0 my $fmtmod_pm = $fmtmod; $fmtmod_pm =~ s!::!/!g; $fmtmod_pm .= ".pm";
2143 0 require $fmtmod_pm;
2144 0 push @fmtobjs, $fmtmod->new(%$fmtargs);
2145 }
2146  
2147 # run all munge_result()
2148 0 for my $fmtobj (@fmtobjs) {
2149 0 ▶ next unless $fmtobj->can("munge_result");
Branch: 1 branch
BranchTrueFalseTotal
unless $fmtobj->can("munge_result") 0 0 0
2150 0 $fmtobj->munge_result($envres);
2151 }
2152  
2153 # return the first render_result()
2154 0 for my $fmtobj (@fmtobjs) {
2155 0 ▶ next unless $fmtobj->can("render_result");
Branch: 1 branch
BranchTrueFalseTotal
unless $fmtobj->can("render_result") 0 0 0
2156 0 return $fmtobj->render_result($envres);
2157 }
2158  
2159 # no render_result() has been called, we return the envres
2160 0 $envres;
2161 }
2162  
2163 # in enhanced mode, foo_bar becomes subscript etc. we don't want this. chart
2164 # title can be non-enhanced with title => { text=>..., enhanced=>0 }, but
2165 # dataset title can't. so we use escape stuffs.
2166 0 ▶sub _esc_gnuplot_title {
Subroutine _esc_gnuplot_title: not called CC=1 SCAR=6.9
2167 0 my $val = shift;
2168 0 $val =~ s/_/-/g; # XXX superscript, greek?
2169 0 $val;
2170 }
2171  
2172 $SPEC{chart_result} = {
2173 3 v => 1.1,
2174 summary => 'Generate chart from the result',
2175 description => <<'_',
2176  
2177 Will use gnuplot (via <pm:Chart::Gnuplot>) to generate the chart. Will produce
2178 `.png` files in the specified directory.
2179  
2180 Currently only results with one or two permutations of different items will be
2181 chartable.
2182  
2183 Options to customize the look/style of the chart will be added in the future.
2184  
2185 _
2186 args => {
2187 envres => {
2188 summary => 'Enveloped result from bencher',
2189 schema => 'array*', # XXX envres
2190 req => 1,
2191 pos => 0,
2192 },
2193 output_file => {
2194 summary => '',
2195 schema => 'str*', # XXX filename
2196 req => 1,
2197 pos => 1,
2198 cmdline_aliases => {o=>{}},
2199 tags => ['category:output'],
2200 },
2201 overwrite => {
2202 schema => 'bool',
2203 tags => ['category:output'],
2204 },
2205 title => {
2206 schema => 'str*',
2207 },
2208 },
2209 };
2210 0 ▶sub chart_result {
Subroutine chart_result: not called CC=9 SCAR=45.0
Pod documented
2211 0 require Chart::Gnuplot;
2212  
2213 0 my %args = @_;
2214  
2215 return [412, "Output file already exists, use overwrite=1 if you want to ".
2216 "overwrite the file"]
2217 0 ▶ if (-f $args{output_file}) && !$args{overwrite};
Branch: 1 branch
BranchTrueFalseTotal
if -f $args{"output_file"} and not $args{"overwrite"} 0 0 0
Condition0%0/3
-f $args{"output_file"} and not $args{"overwrite"}
!ll&&!rl&&r
000
MC/DC0%0/2
-f $args{"output_file"} and not $args{"overwrite"}
-f $args{"output_file"} not $args{"overwrite"}
Truth table0%0/3
A and not(B)
A= -f $args{"output_file"}B= not $args{"overwrite"}
ABresult
0X0
100
111
2218 0 ▶ return [412, "Result has no items, can't chart"] unless @{$args{envres}[2]};
Branch: 1 branch
BranchTrueFalseTotal
unless @{$args{"envres"}[2];} 0 0 0
2219 0 my $envres = format_result($args{envres}, undef, {render_as_text_table=>0});
2220 0 _set_item_names($envres->[2]);
2221 0 ▶ my $data = $envres->[3]{'func.module_startup'} || $envres->[3]{'func.code_startup'} ? "time" : "rate";
Branch: 1 branch
BranchTrueFalseTotal
$envres->[3]{'func.module_startup'} || $envres->[3]{'func.code_startup'} ? : 0 0 0
Condition0%0/3
$envres->[3]{"func.module_startup"} or $envres->[3]{"func.code_startup"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$envres->[3]{"func.module_startup"} or $envres->[3]{"func.code_startup"}
$envres->[3]{"func.module_startup"} $envres->[3]{"func.code_startup"}
Truth table0%0/3
A or B
A= $envres->[3]{"func.module_startup"}B= $envres->[3]{"func.code_startup"}
ABresult
1X1
011
000
2222  
2223 my $chart = Chart::Gnuplot->new(
2224 #imagesize => "0.5, 0.5",
2225 output => $args{output_file},
2226 0 ▶ title => $args{title} // 'Benchmark result'.($data eq 'rate' ? " (higher is better)" : "(shorter is better)"),
Branch: 1 branch
BranchTrueFalseTotal
$data eq 'rate' ? : 0 0 0
Condition0%0/2
$args{"title"} // 'Benchmark result' . ($data eq "rate" ? " (higher is better)" : "(shorter is better)")
l!l
00
MC/DC0%0/1
$args{"title"} // 'Benchmark result' . ($data eq "rate" ? " (higher is better)" : "(shorter is better)")
$args{"title"}
Truth table0%0/2
A
A= $args{"title"}
Aresult
11
00
2227 ylabel => $data,
2228 xlabel => "",
2229 xtics => {rotate=>"30 right"},
2230 );
2231  
2232 0 my (@ydata, @xdata);
2233 0 for my $it (@{ $envres->[2] }) {
2234 0 push @xdata, _esc_gnuplot_title($it->{_succinct_name});
2235 0 push @ydata, $it->{$data};
2236 }
2237 0 my @chart_datasets;
2238 0 my $ds = Chart::Gnuplot::DataSet->new(
2239 ydata => \@ydata,
2240 xdata => \@xdata,
2241 title => "",
2242 border => undef,
2243 fill => {}, # XXX color doesn't affect, on my PC?
2244 style => "histograms",
2245 );
2246 0 push @chart_datasets, $ds;
2247 0 $chart->plot2d(@chart_datasets);
2248 0 [200, "OK"];
2249 }
2250  
2251 $SPEC{split_result} = {
2252 3 v => 1.1,
2253 summary => 'Split results based on one or more fields',
2254 description => <<'_',
2255  
2256 This routine splits a table into multiple table based on one or more fields. If
2257 you want to split a result, you should do it before `format_result()` and then
2258 format the split results individually.
2259  
2260 A common use-case is to produce separate tables for each participant or dataset,
2261 to make the benchmark results more readable (this is an alternative to having to
2262 perform separate benchmark run per participant or dataset).
2263  
2264 Each split result clones all the result metadata (like `func.module_version`,
2265 `func.platform_info`, `table.fields`, and so on). But the result items are only
2266 a subset of the original result.
2267  
2268 Return an array where each element is `[\%field_values, $split_result]`.
2269  
2270 _
2271 args => {
2272 envres => {
2273 summary => 'Enveloped result from bencher',
2274 schema => 'array*', # XXX envres
2275 req => 1,
2276 pos => 0,
2277 },
2278 fields => {
2279 'x.name.is_plural' => 1,
2280 'x.name.singular' => 'field',
2281 summary => 'Fields to split the results on',
2282 schema => ['array*', of=>'str*'],
2283 req => 1,
2284 pos => 1,
2285 },
2286 options => {
2287 'x.name.is_plural' => 1,
2288 'x.name.singular' => 'option',
2289 schema => 'hash*',
2290 pos => 2,
2291 },
2292 },
2293 args_as => 'array',
2294 result_naked => 1,
2295 };
2296 0 ▶sub split_result {
Subroutine split_result: not called CC=6 SCAR=35.1
Pod documented
2297 3 ▶ no warnings 'uninitialized';
Subroutine BEGIN: called CC=1 SCAR=0.0
2298  
2299 0 require Data::Clone;
2300  
2301 0 my ($envres, $fields, $opts) = @_;
2302  
2303 0 ▶ $opts //= {};
Condition0%0/2
$opts //= {}
l!l
00
MC/DC0%0/1
$opts //= {}
$opts
Truth table0%0/2
A
A= $opts
Aresult
11
00
2304  
2305 0 my %idxs_by_key; # key= "field1-value\0field2-value\0...", val=[index of item in envres->[2], ...]
2306  
2307 0 for my $i (0..$#{ $envres->[2] }) {
2308 0 my $item = $envres->[2][$i];
2309 0 my $key = join("\0", map { $item->{$_} } @$fields);
2310 0 push @{ $idxs_by_key{$key} }, $i;
2311 }
2312  
2313 0 my $res = [];
2314 0 for my $key (sort keys %idxs_by_key) {
2315 0 my $split_res = Data::Clone::clone($envres);
2316 0 $split_res->[2] = [map { $split_res->[2][$_] } @{ $idxs_by_key{$key} }];
2317 0 my $split_fields = { map { $_ => $split_res->[2][0]{$_} } @$fields };
2318  
2319 0 ▶ if ($split_res->[3]{'func.permute'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($split_res->[3]{"func.permute"}) 0 0 0
2320 0 my %permute = @{ $split_res->[3]{'func.permute'} };
2321 0 delete $permute{$_} for keys %$split_fields;
2322 $split_res->[3]{'func.permute'} =
2323 0 [map { $_=>$permute{$_} } sort keys %permute];
2324 }
2325  
2326 0 push @$res, [$split_fields, $split_res];
2327 }
2328  
2329 0 $res;
2330 }
2331  
2332 0 ▶my $_code_remaining = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
2333 0 my ($seen_elems, $elems) = @_;
2334 0 my %seen;
2335 0 for (@$seen_elems) {
2336 0 (my $nodash = $_) =~ s/^-//;
2337 0 $seen{$nodash}++;
2338 }
2339 0 my @remaining;
2340 0 for (@$elems) {
2341 0 (my $nodash = $_) =~ s/^-//;
2342 0 ▶ push @remaining, $_ unless $seen{$nodash};
Branch: 1 branch
BranchTrueFalseTotal
unless $seen{$nodash} 0 0 0
2343 }
2344 0 \@remaining;
2345 3 };
2346  
2347 $SPEC{bencher} = {
2348 v => 1.1,
2349 summary => 'A benchmark framework',
2350 description => <<'_',
2351  
2352 Bencher is a benchmark framework. You specify a *scenario* (either in a
2353 `Bencher::Scenario::*` Perl module, or a Perl script, or over the command-line)
2354 containing list of *participants* and *datasets*. Participants are codes or
2355 commands to run, and datasets are arguments for the codes/commands. Bencher will
2356 permute the participants and datasets into benchmark items, ready to run.
2357  
2358 You can choose to include only some participants, datasets, or items. And there
2359 are options to view your scenario's participants/datasets/items/mentioned
2360 modules, run benchmark against multiple perls and module versions, and so on.
2361 Bencher comes as a CLI script as well as Perl module. See the
2362 <pm:Bencher::Backend> documentation for more information.
2363  
2364 _
2365 args_rels => {
2366 # XXX precision & precision_limit is only relevant when action =~ /^bench(-with-.+)?$/
2367 # XXX note is only relevant when action=bench
2368 # XXX sort is only relevant when action=bench and format=text
2369 # XXX include_perls & exclude_perls are only relevant when multiperl=1
2370 'choose_one&' => [
2371 ['scenario_file', 'scenario_module', 'scenario', 'cpanmodules_module'],
2372 ['module_startup', 'code_startup'],
2373 ],
2374 },
2375 args => {
2376 scenario_file => {
2377 summary => 'Load a scenario from a Perl file',
2378 description => <<'_',
2379  
2380 Perl file will be do()'ed and the last expression should be a hash containing
2381 the scenario specification.
2382  
2383 _
2384 schema => ['str*'],
2385 cmdline_aliases => {f=>{}},
2386 tags => ['category:scenario', 'category:participant'],
2387 },
2388 scenario_module => {
2389 summary => 'Load a scenario from a Bencher::Scenario:: Perl module',
2390 description => <<'_',
2391  
2392 Will try to load module `Bencher::Scenario::<NAME>` and expect to find a package
2393 variable in the module called `$scenario` which should be a hashref containing
2394 the scenario specification.
2395  
2396 _
2397 schema => 'perl::modname*',
2398 cmdline_aliases => {m=>{}},
2399 0 ▶ completion => sub { _complete_scenario_module(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2400 tags => ['category:scenario', 'category:participant'],
2401 },
2402 cpanmodules_module => {
2403 summary => 'Load a scenario from an Acme::CPANModules:: Perl module',
2404 description => <<'_',
2405  
2406 An <pm:Acme::CPANModules> module can also contain benchmarking information, e.g.
2407 <pm:Acme::CPANModules::TextTable>.
2408  
2409 _
2410 schema => 'perl::modname*',
2411 0 ▶ completion => sub { _complete_cpanmodules_module(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2412 tags => ['category:scenario', 'category:participant'],
2413 },
2414 scenario => {
2415 summary => 'Load a scenario from data structure',
2416 schema => ['hash*'], # XXX bencher::scenario
2417 tags => ['hidden-cli'],
2418 tags => ['category:scenario', 'category:participant'],
2419 },
2420 participants => {
2421 'summary' => 'Add participants',
2422 schema => ['array*', of=>['hash*']],
2423 cmdline_aliases => {
2424 participant => $_alias_spec_add_participant,
2425 p => $_alias_spec_add_participant,
2426 },
2427 tags => ['category:participant'],
2428 },
2429 datasets => {
2430 summary => 'Add datasets',
2431 schema => ['array*', of=>['hash*']],
2432 cmdline_aliases => {
2433 dataset => $_alias_spec_add_dataset,
2434 d => $_alias_spec_add_dataset,
2435 },
2436 tags => ['category:dataset'],
2437 },
2438 env_hashes => {
2439 summary => 'Add environment hashes',
2440 schema => ['array*', of=>['hash*']],
2441 cmdline_aliases => {
2442 env_hash => $_alias_spec_add_env_hash,
2443 },
2444 },
2445 precision => {
2446 summary => 'Precision',
2447 description => <<'_',
2448  
2449 When benchmarking with the default <pm:Benchmark::Dumb> runner, will pass the
2450 precision to it. The value is a fraction, e.g. 0.5 (for 5% precision), 0.01 (for
2451 1% precision), and so on. Or, it can also be a positive integer to speciify
2452 minimum number of iterations, usually need to be at least 6 to avoid the "Number
2453 of initial runs is very small (<6)" warning. The default precision is 0, which
2454 is to let Benchmark::Dumb determine the precision, which is good enough for most
2455 cases.
2456  
2457 When benchmarking with <pm:Benchmark> runner, will pass this value as the
2458 C<$count> argument. Which can be a positive integer to mean the number of
2459 iterations to do (e.g. 10, or 100). Or, can also be set to a negative number
2460 (e.g. -0.5 or -2) to mean minimum number of CPU seconds. The default is -0.5.
2461  
2462 When benchmarking with <pm:Benchmark::Dumb::SimpleTime>, this value is a
2463 positive integer which means the number of iterations to perform.
2464  
2465 When profiling, a number greater than 1 will set a repetition loop (e.g. C<<
2466 for(1..100){ ... } >>).
2467  
2468 This setting overrides `default_precision` property in the scenario.
2469  
2470 _
2471 schema => ['float*'],
2472 },
2473 precision_limit => {
2474 summary => 'Set precision limit',
2475 description => <<'_',
2476  
2477 Instead of setting `precision` which forces a single value, you can also set
2478 this `precision_limit` setting. If the precision in the scenario is higher
2479 (=number is smaller) than this limit, then this limit is used. For example, if
2480 the scenario specifies `default_precision` 0.001 and `precision_limit` is set to
2481 0.005 then 0.005 is used.
2482  
2483 This setting is useful on slower computers which might not be able to reach the
2484 required precision before hitting maximum number of iterations.
2485  
2486 _
2487 schema => ['float*', between=>[0,1]],
2488 },
2489 action => {
2490 schema => ['str*', {
2491 in=>[qw/
2492 list-perls
2493 list-scenario-modules
2494 show-scenario
2495 list-participants
2496 list-participant-modules
2497 list-datasets
2498 list-items
2499 show-items-codes
2500 show-items-results
2501 show-items-results-sizes
2502 show-items-outputs
2503 dump-items
2504 dump-parsed-scenario
2505 profile
2506 bench
2507 /]
2508 # list-functions
2509 }],
2510 default => 'bench',
2511 cmdline_aliases => {
2512 a => {},
2513 list_perls => {
2514 is_flag => 1,
2515 summary => 'Shortcut for -a list-perls',
2516 0 ▶ code => sub { $_[0]{action} = 'list-perls' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2517 },
2518 list_scenario_modules => {
2519 is_flag => 1,
2520 summary => 'Shortcut for -a list-scenario-modules',
2521 0 ▶ code => sub { $_[0]{action} = 'list-scenario-modules' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2522 },
2523 L => {
2524 is_flag => 1,
2525 summary => 'Shortcut for -a list-scenario-modules',
2526 0 ▶ code => sub { $_[0]{action} = 'list-scenario-modules' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2527 },
2528 show_scenario => {
2529 is_flag => 1,
2530 summary => 'Shortcut for -a show-scenario',
2531 0 ▶ code => sub { $_[0]{action} = 'show-scenario' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2532 },
2533 list_participants => {
2534 is_flag => 1,
2535 summary => 'Shortcut for -a list-participants',
2536 0 ▶ code => sub { $_[0]{action} = 'list-participants' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2537 },
2538 list_participant_modules => {
2539 is_flag => 1,
2540 summary => 'Shortcut for -a list-participant-modules',
2541 0 ▶ code => sub { $_[0]{action} = 'list-participant-modules' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2542 },
2543 list_datasets => {
2544 is_flag => 1,
2545 summary => 'Shortcut for -a list-datasets',
2546 0 ▶ code => sub { $_[0]{action} = 'list-datasets' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2547 },
2548 list_permutes => {
2549 is_flag => 1,
2550 summary => 'Shortcut for -a list-permutes',
2551 0 ▶ code => sub { $_[0]{action} = 'list-permutes' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2552 },
2553 list_items => {
2554 is_flag => 1,
2555 summary => 'Shortcut for -a list-items',
2556 0 ▶ code => sub { $_[0]{action} = 'list-items' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2557 },
2558 show_items_codes => {
2559 is_flag => 1,
2560 summary => 'Shortcut for -a show-items-codes',
2561 0 ▶ code => sub { $_[0]{action} = 'show-items-codes' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2562 },
2563 show_items_results => {
2564 is_flag => 1,
2565 summary => 'Shortcut for -a show-items-results',
2566 0 ▶ code => sub { $_[0]{action} = 'show-items-results' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2567 },
2568 show_items_results_sizes => {
2569 is_flag => 1,
2570 summary => 'Shortcut for -a show-items-results-sizes',
2571 0 ▶ code => sub { $_[0]{action} = 'show-items-results-sizes' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2572 },
2573 show_items_outputs => {
2574 is_flag => 1,
2575 summary => 'Shortcut for -a show-items-outputs',
2576 0 ▶ code => sub { $_[0]{action} = 'show-items-outputs' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2577 },
2578 dump_items => {
2579 is_flag => 1,
2580 summary => 'Shortcut for -a dump-items',
2581 0 ▶ code => sub { $_[0]{action} = 'dump-items' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2582 },
2583 dump_parsed_scenario => {
2584 is_flag => 1,
2585 summary => 'Shortcut for -a dump-parsed-scenario',
2586 0 ▶ code => sub { $_[0]{action} = 'dump-parsed-scenario' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2587 },
2588 profile => {
2589 is_flag => 1,
2590 summary => 'Shortcut for -a profile',
2591 0 ▶ code => sub { $_[0]{action} = 'profile' },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2592 },
2593 },
2594 tags => ['category:action'],
2595 },
2596 raw => {
2597 summary => 'Show "raw" data',
2598 schema => ['bool'],
2599 description => <<'_',
2600  
2601 When action=show-items-result, will print result as-is instead of dumping as
2602 Perl.
2603  
2604 _
2605 tags => ['category:output'],
2606 },
2607 test => {
2608 summary => 'Whether to test participant code once first before benchmarking',
2609 schema => ['bool*'],
2610 description => <<'_',
2611  
2612 By default, participant code is run once first for testing (e.g. whether it dies
2613 or return the correct result) before benchmarking. If your code runs for many
2614 seconds, you might want to skip this test and set this to 0.
2615  
2616 _
2617 },
2618 module_startup => {
2619 schema => ['bool*', is=>1],
2620 summary => 'Benchmark module startup overhead instead of normal benchmark',
2621 tags => ['category:action'],
2622 },
2623 code_startup => {
2624 schema => ['bool*', is=>1],
2625 summary => 'Benchmark code startup overhead instead of normal benchmark',
2626 tags => ['category:action'],
2627 },
2628 detail => {
2629 summary => 'Show detailed information for each result',
2630 schema => ['bool*'],
2631 cmdline_aliases => {l=>{}},
2632 },
2633  
2634 runner => {
2635 summary => 'Runner module to use',
2636 schema => ['str*', {
2637 in=>[
2638 'Benchmark::Dumb',
2639 'Benchmark',
2640 'Benchmark::Dumb::SimpleTime',
2641 ],
2642 }],
2643 description => <<'_',
2644  
2645 The default is `Benchmark::Dumb` which should be good enough for most cases.
2646  
2647 You can use `Benchmark` runner (`Benchmark.pm`) if you are accustomed to it and
2648 want to see its output format.
2649  
2650 You can use `Benchmark::Dumb::SimpleTime` if your participant code runs for at
2651 least a few to many seconds and you want to use very few iterations (like 1 or
2652 2) because you don't want to wait for too long.
2653  
2654 _
2655 },
2656  
2657 include_modules => {
2658 'x.name.is_plural' => 1,
2659 summary => 'Only include modules specified in this list',
2660 'summary.alt.plurality.singular' => 'Add module to include list',
2661 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2662 0 ▶ element_completion => sub { _complete_participant_module(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2663 0 ▶ completion => sub { _complete_participant_modules_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2664 tags => ['category:filtering'],
2665 },
2666 include_module_pattern => {
2667 summary => 'Only include modules matching this regex pattern',
2668 schema => ['re*'],
2669 tags => ['category:filtering'],
2670 },
2671 exclude_modules => {
2672 'x.name.is_plural' => 1,
2673 summary => 'Exclude modules specified in this list',
2674 'summary.alt.plurality.singular' => 'Add module to exclude list',
2675 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2676 0 ▶ element_completion => sub { _complete_participant_module(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2677 0 ▶ completion => sub { _complete_participant_modules_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2678 tags => ['category:filtering'],
2679 },
2680 exclude_module_pattern => {
2681 summary => 'Exclude module(s) matching this regex pattern',
2682 schema => ['re*'],
2683 tags => ['category:filtering'],
2684 },
2685  
2686 exclude_xs_modules => {
2687 summary => 'Exclude XS modules',
2688 schema => ['bool*', is=>1],
2689 cmdline_aliases => { noxs => {is_flag=>1} },
2690 tags => ['category:filtering'],
2691 },
2692 exclude_pp_modules => {
2693 summary => 'Exclude PP (pure-Perl) modules',
2694 schema => ['bool*', is=>1],
2695 cmdline_aliases => { nopp => {is_flag=>1} },
2696 tags => ['category:filtering'],
2697 },
2698  
2699 include_functions => {
2700 'x.name.is_plural' => 1,
2701 summary => 'Only include functions specified in this list',
2702 'summary.alt.plurality.singular' => 'Add function to include list',
2703 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2704 0 ▶ element_completion => sub { _complete_function(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2705 0 ▶ completion => sub { _complete_functions_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2706 tags => ['category:filtering'],
2707 },
2708 include_function_pattern => {
2709 summary => 'Only include functions matching this regex pattern',
2710 schema => ['re*'],
2711 tags => ['category:filtering'],
2712 },
2713 exclude_functions => {
2714 'x.name.is_plural' => 1,
2715 summary => 'Exclude functions specified in this list',
2716 'summary.alt.plurality.singular' => 'Add function to exclude list',
2717 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2718 0 ▶ element_completion => sub { _complete_function(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2719 0 ▶ completion => sub { _complete_functions_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2720 tags => ['category:filtering'],
2721 },
2722 exclude_function_pattern => {
2723 summary => 'Exclude function(s) matching this regex pattern',
2724 schema => ['re*'],
2725 tags => ['category:filtering'],
2726 },
2727  
2728 include_participants => {
2729 'x.name.is_plural' => 1,
2730 summary => 'Only include participants whose seq/name matches this',
2731 'summary.alt.plurality.singular' => 'Add participant (by name/seq) to include list',
2732 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2733 0 ▶ element_completion => sub { _complete_participant(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2734 0 ▶ completion => sub { _complete_participants_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2735 tags => ['category:filtering'],
2736 },
2737 include_participant_names => {
2738 'x.name.is_plural' => 1,
2739 summary => 'Only include participants whose name matches this',
2740 'summary.alt.plurality.singular' => 'Add participant (by name) to include list',
2741 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2742 0 ▶ element_completion => sub { _complete_participant(@_, apply_filters=>0, seq=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2743 0 ▶ completion => sub { _complete_participant_names_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2744 tags => ['category:filtering'],
2745 },
2746 include_participant_seqs => {
2747 'x.name.is_plural' => 1,
2748 summary => 'Only include participants whose sequence number matches this',
2749 'summary.alt.plurality.singular' => 'Add participant (by sequence number) to include list',
2750 schema => ['array*', of=>['int*', min=>0], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2751 0 ▶ element_completion => sub { _complete_participant(@_, apply_filters=>0, name=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2752 0 ▶ completion => sub { _complete_participant_seqs_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2753 tags => ['category:filtering'],
2754 },
2755 include_participant_pattern => {
2756 summary => 'Only include participants matching this regex pattern',
2757 schema => ['re*'],
2758 tags => ['category:filtering'],
2759 },
2760 include_participant_tags => {
2761 'x.name.is_plural' => 1,
2762 summary => 'Only include participants whose tag matches this',
2763 'summary.alt.plurality.singular' => 'Add a tag to participants include tag list',
2764 description => <<'_',
2765  
2766 You can specify `A & B` to include participants that have _both_ tags A and B.
2767  
2768 _
2769 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2770 0 ▶ element_completion => sub { _complete_participant_tag(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2771 0 ▶ completion => sub { _complete_participant_tags_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2772 tags => ['category:filtering'],
2773 },
2774 exclude_participants => {
2775 'x.name.is_plural' => 1,
2776 summary => 'Exclude participants whose seq/name matches this',
2777 'summary.alt.plurality.singular' => 'Add participant (by name/seq) to exclude list',
2778 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2779 0 ▶ element_completion => sub { _complete_participant(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2780 0 ▶ completion => sub { _complete_participants_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2781 tags => ['category:filtering'],
2782 },
2783 exclude_participant_names => {
2784 'x.name.is_plural' => 1,
2785 summary => 'Exclude participants whose name matches this',
2786 'summary.alt.plurality.singular' => 'Add participant (by name) to exclude list',
2787 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2788 0 ▶ element_completion => sub { _complete_participant(@_, apply_filters=>0, seq=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2789 0 ▶ completion => sub { _complete_participant_names_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2790 tags => ['category:filtering'],
2791 },
2792 exclude_participant_seqs => {
2793 'x.name.is_plural' => 1,
2794 summary => 'Exclude participants whose sequence number matches this',
2795 'summary.alt.plurality.singular' => 'Add participant (by sequence number) to exclude list',
2796 schema => ['array*', of=>['int*', min=>0], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2797 0 ▶ element_completion => sub { _complete_participant(@_, apply_filters=>0, name=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2798 0 ▶ completion => sub { _complete_participant_seqs_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2799 tags => ['category:filtering'],
2800 },
2801 exclude_participant_pattern => {
2802 summary => 'Exclude participants matching this regex pattern',
2803 schema => ['re*'],
2804 tags => ['category:filtering'],
2805 },
2806 exclude_participant_tags => {
2807 'x.name.is_plural' => 1,
2808 summary => 'Exclude participants whose tag matches this',
2809 'summary.alt.plurality.singular' => 'Add a tag to participants exclude tag list',
2810 description => <<'_',
2811  
2812 You can specify `A & B` to exclude participants that have _both_ tags A and B.
2813  
2814 _
2815 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2816 0 ▶ element_completion => sub { _complete_participant_tag(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2817 0 ▶ completion => sub { _complete_participant_tags_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2818 tags => ['category:filtering'],
2819 },
2820  
2821 include_items => {
2822 'x.name.is_plural' => 1,
2823 summary => 'Only include items whose seq/name matches this',
2824 'summary.alt.plurality.singular' => 'Add item (by name/seq) to include list',
2825 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2826 0 ▶ element_completion => sub { _complete_item(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2827 0 ▶ completion => sub { _complete_items_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2828 tags => ['category:filtering'],
2829 },
2830 include_item_names => {
2831 'x.name.is_plural' => 1,
2832 summary => 'Only include items whose name matches this',
2833 'summary.alt.plurality.singular' => 'Add item (by name) to include list',
2834 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2835 0 ▶ element_completion => sub { _complete_item(@_, apply_filters=>0, seq=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2836 0 ▶ completion => sub { _complete_item_names_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2837 tags => ['category:filtering'],
2838 },
2839 include_item_seqs => {
2840 'x.name.is_plural' => 1,
2841 summary => 'Only include items whose sequence number matches this',
2842 'summary.alt.plurality.singular' => 'Add item (by sequence number) to include list',
2843 schema => ['array*', of=>['int*', min=>0], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2844 0 ▶ element_completion => sub { _complete_item(@_, apply_filters=>0, name=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2845 0 ▶ completion => sub { _complete_item_seqs_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2846 tags => ['category:filtering'],
2847 },
2848 include_item_pattern => {
2849 summary => 'Only include items matching this regex pattern',
2850 schema => ['re*'],
2851 tags => ['category:filtering'],
2852 },
2853 exclude_items => {
2854 'x.name.is_plural' => 1,
2855 summary => 'Exclude items whose seq/name matches this',
2856 'summary.alt.plurality.singular' => 'Add item (by name/seq) to exclude list',
2857 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2858 0 ▶ element_completion => sub { _complete_item(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2859 0 ▶ completion => sub { _complete_items_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2860 tags => ['category:filtering'],
2861 },
2862 exclude_item_names => {
2863 'x.name.is_plural' => 1,
2864 summary => 'Exclude items whose name matches this',
2865 'summary.alt.plurality.singular' => 'Add item (by name) to exclude list',
2866 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2867 0 ▶ element_completion => sub { _complete_item(@_, apply_filters=>0, seq=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2868 0 ▶ completion => sub { _complete_item_names_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2869 tags => ['category:filtering'],
2870 },
2871 exclude_item_seqs => {
2872 'x.name.is_plural' => 1,
2873 summary => 'Exclude items whose sequence number matches this',
2874 'summary.alt.plurality.singular' => 'Add item (by sequence number) to exclude list',
2875 schema => ['array*', of=>['int*', min=>0], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2876 0 ▶ element_completion => sub { _complete_item(@_, apply_filters=>0, name=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2877 0 ▶ completion => sub { _complete_item_seqs_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2878 tags => ['category:filtering'],
2879 },
2880 exclude_item_pattern => {
2881 summary => 'Exclude items matching this regex pattern',
2882 schema => ['re*'],
2883 tags => ['category:filtering'],
2884 },
2885  
2886 include_datasets => {
2887 'x.name.is_plural' => 1,
2888 summary => 'Only include datasets whose seq/name matches this',
2889 'summary.alt.plurality.singular' => 'Add dataset (by name/seq) to include list',
2890 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2891 0 ▶ element_completion => sub { _complete_dataset(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2892 0 ▶ completion => sub { _complete_datasets_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2893 tags => ['category:filtering'],
2894 },
2895 include_dataset_names => {
2896 'x.name.is_plural' => 1,
2897 summary => 'Only include datasets whose name matches this',
2898 'summary.alt.plurality.singular' => 'Add dataset (by name) to include list',
2899 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2900 0 ▶ element_completion => sub { _complete_dataset(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2901 0 ▶ completion => sub { _complete_dataset_names_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2902 tags => ['category:filtering'],
2903 },
2904 include_dataset_seqs => {
2905 'x.name.is_plural' => 1,
2906 summary => 'Only include datasets whose sequence number matches this',
2907 'summary.alt.plurality.singular' => 'Add dataset (by sequence number) to include list',
2908 schema => ['array*', of=>['int*', min=>0], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2909 0 ▶ element_completion => sub { _complete_dataset(@_, apply_filters=>0, name=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2910 0 ▶ completion => sub { _complete_dataset_seqs_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2911 tags => ['category:filtering'],
2912 },
2913 include_dataset_pattern => {
2914 summary => 'Only include datasets matching this regex pattern',
2915 schema => ['re*'],
2916 tags => ['category:filtering'],
2917 },
2918 exclude_datasets => {
2919 'x.name.is_plural' => 1,
2920 summary => 'Exclude datasets whose seq/name matches this',
2921 'summary.alt.plurality.singular' => 'Add dataset (by name/seq) to exclude list',
2922 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2923 0 ▶ element_completion => sub { _complete_dataset(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2924 0 ▶ completion => sub { _complete_datasets_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2925 tags => ['category:filtering'],
2926 },
2927 exclude_dataset_names => {
2928 'x.name.is_plural' => 1,
2929 summary => 'Exclude datasets whose name matches this',
2930 'summary.alt.plurality.singular' => 'Add dataset (by name) to exclude list',
2931 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2932 0 ▶ element_completion => sub { _complete_dataset(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2933 0 ▶ completion => sub { _complete_dataset_names_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2934 tags => ['category:filtering'],
2935 },
2936 exclude_dataset_seqs => {
2937 'x.name.is_plural' => 1,
2938 summary => 'Exclude datasets whose sequence number matches this',
2939 'summary.alt.plurality.singular' => 'Add dataset (by sequence number) to exclude list',
2940 schema => ['array*', of=>['int*', min=>0], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2941 0 ▶ element_completion => sub { _complete_dataset(@_, apply_filters=>0, name=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2942 0 ▶ completion => sub { _complete_dataset_seqs_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2943 tags => ['category:filtering'],
2944 },
2945 exclude_dataset_pattern => {
2946 summary => 'Exclude datasets matching this regex pattern',
2947 schema => ['re*'],
2948 tags => ['category:filtering'],
2949 },
2950 include_dataset_tags => {
2951 'x.name.is_plural' => 1,
2952 summary => 'Only include datasets whose tag matches this',
2953 'summary.alt.plurality.singular' => 'Add a tag to dataset include tag list',
2954 description => <<'_',
2955  
2956 You can specify `A & B` to include datasets that have _both_ tags A and B.
2957  
2958 _
2959 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2960 0 ▶ element_completion => sub { _complete_dataset_tag(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2961 0 ▶ completion => sub { _complete_dataset_tags_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2962 tags => ['category:filtering'],
2963 },
2964 exclude_dataset_tags => {
2965 'x.name.is_plural' => 1,
2966 summary => 'Exclude datasets whose tag matches this',
2967 'summary.alt.plurality.singular' => 'Add a tag to dataset exclude tag list',
2968 description => <<'_',
2969  
2970 You can specify `A & B` to exclude datasets that have _both_ tags A and B.
2971  
2972 _
2973 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
2974 0 ▶ element_completion => sub { _complete_dataset_tag(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2975 0 ▶ completion => sub { _complete_dataset_tags_comma_sep(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
2976 tags => ['category:filtering'],
2977 },
2978 multiperl => {
2979 summary => 'Benchmark against multiple perls',
2980 schema => ['bool'],
2981 default => 0,
2982 description => <<'_',
2983  
2984 Requires <pm:App::perlbrew> to be installed. Will use installed perls from the
2985 perlbrew installation. Each installed perl must have <pm:Bencher::Backend>
2986 module installed (in addition to having all modules that you want to benchmark,
2987 obviously).
2988  
2989 By default, only perls having Bencher::Backend will be included. Use
2990 `--include-perl` and `--exclude-perl` to include and exclude which perls you
2991 want.
2992  
2993 Also note that due to the way this is currently implemented, benchmark code that
2994 contains closures (references to variables outside the code) won't work.
2995  
2996 _
2997 tags => ['category:multiperl'],
2998 },
2999 include_perls => {
3000 'x.name.is_plural' => 1,
3001 summary => 'Only include some perls',
3002 'summary.alt.plurality.singular' => 'Add specified perl to include list',
3003 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
3004 0 ▶ element_completion => sub { _complete_perl(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
3005 tags => ['category:filtering', 'category:multiperl'],
3006 },
3007 exclude_perls => {
3008 'x.name.is_plural' => 1,
3009 summary => 'Exclude some perls',
3010 'summary.alt.plurality.singular' => 'Add specified perl to exclude list',
3011 schema => ['array*', of=>['str*'], 'x.perl.coerce_rules' => ['From_str::comma_sep']],
3012 0 ▶ element_completion => sub { _complete_perl(@_) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
3013 tags => ['category:filtering', 'category:multiperl'],
3014 },
3015  
3016 multimodver => {
3017 summary => 'Benchmark multiple module versions',
3018 schema => ['perl::modname*'],
3019 description => <<'_',
3020  
3021 If set to a module name, will search for all (instead of the first occurrence)
3022 of the module in `@INC`. Then will generate items for each version.
3023  
3024 Currently only one module can be multi version.
3025  
3026 _
3027 0 ▶ completion => sub { _complete_participant_module(@_, apply_filters=>0) },
Subroutine __ANON__: not called CC=1 SCAR=6.9
3028 tags => ['category:multi-module-version'],
3029 },
3030 include_path => {
3031 summary => 'Additional module search paths',
3032 'summary.alt.plurality.singular' => 'Add path to module search path',
3033 schema => ['array*', of=>['str*'],
3034  
3035 # for now we disable this because: when doing completion
3036 # we are not using validation/coercion from Data::Sah, so
3037 # include_path will still be a string instead of array,
3038 # and this breaks routines that expect this argument to
3039 # be an array
3040  
3041 #'x.perl.coerce_rules' => ['From_str::comma_sep'],
3042 ],
3043 description => <<'_',
3044  
3045 Used when searching for scenario module, or when in multimodver mode.
3046  
3047 _
3048 cmdline_aliases => {I=>{}},
3049 tags => ['category:multi-module-version'],
3050 },
3051 # XXX include-mod-version
3052 # XXX exclude-mod-version
3053  
3054  
3055 # code_before => {
3056 # summary => 'Run perl code when running in multiperl or multi-module-version mode',
3057 # schema => ['array*', of=>'str*'],
3058 # description => <<'_',
3059  
3060 # Due to the way multiperl (`--multiperl`) and multi-module-version
3061 # (`--multimodver`) modes are currently implemented, code templates of the
3062 # participants are first turned into coderefs then dumped into a temporary script.
3063 # Each benchmark item is then run by a separate perl process.
3064  
3065 # The dumped coderef code might lack e.g. the original `use` statement or code in
3066 # BEGIN block. For example:
3067  
3068 # code_template => q(use MyMod '$foo'; $foo->bar() for 1..1000),
3069  
3070 # when the code template is turned into coderef and dumped:
3071  
3072 # code => sub { $main::foo->bar() for 1..1000 },
3073  
3074 # This is where this option can be used to work around this current limitation. In
3075 # this case, we can add:
3076  
3077 # code_before => 'use Progress::Any q($progress)',
3078  
3079 # _
3080 # tags => ['category:multiperl', 'category:multi-module-version'],
3081 # },
3082  
3083  
3084 on_failure => {
3085 summary => "What to do when there is a failure",
3086 schema => ['str*', in=>[qw/die skip/]],
3087 description => <<'_',
3088  
3089 For a command participant, failure means non-zero exit code. For a Perl-code
3090 participant, failure means Perl code dies or (if expected result is specified)
3091 the result is not equal to the expected result.
3092  
3093 The default is "die". When set to "skip", will first run the code of each item
3094 before benchmarking and trap command failure/Perl exception and if that happens,
3095 will "skip" the item.
3096  
3097 _
3098 },
3099 on_result_failure => {
3100 summary => "What to do when there is a result failure",
3101 schema => ['str*', in=>[qw/die skip warn/]],
3102 description => <<'_',
3103  
3104 This is like `on_failure` except that it specifically refer to the failure of
3105 item's result not being equal to expected result.
3106  
3107 There is an extra choice of `warn` for this type of failure, which is to print a
3108 warning to STDERR and continue.
3109  
3110 _
3111 },
3112  
3113 sorts => {
3114 'x.name.is_plural' => 1,
3115 'x.name.singular' => 'sort',
3116 schema => ['array*', {
3117 of => ['str*'],
3118 min_len => 1,
3119 'x.perl.coerce_rules' => ['From_str::comma_sep'],
3120 }],
3121 default => ['-time'],
3122 0 ▶ element_completion => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
3123 0 require Complete::Util;
3124  
3125 0 my %args = @_;
3126  
3127 # XXX all result fields are okay
3128 0 my $elems = [map {($_,"-$_")}
3129 qw/participant rate time errors samples/];
3130  
3131 my $remaining = $_code_remaining->(
3132 0 ▶ $args{parsed_opts}{'--sort'} // [],
Condition0%0/2
$args{"parsed_opts"}{"--sort"} // []
l!l
00
MC/DC0%0/1
$args{"parsed_opts"}{"--sort"} // []
$args{"parsed_opts"}{"--sort"}
Truth table0%0/2
A
A= $args{"parsed_opts"}{"--sort"}
Aresult
11
00
3133 $elems,
3134 );
3135 Complete::Util::complete_array_elem(
3136 word => $args{word},
3137 0 array => $remaining,
3138 );
3139 },
3140 0 ▶ completion => sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
3141 0 require Complete::Util;
3142 0 my %args = @_;
3143 Complete::Util::complete_comma_sep(
3144 word => $args{word},
3145 # XXX all result fields are okay
3146 0 elems => [map {($_,"-$_")}
3147 qw/participant rate time errors samples/],
3148 remaining => $_code_remaining,
3149 );
3150 },
3151 3 tags => ['category:output'],
3152 },
3153 scientific_notation => {
3154 schema => ['bool', is=>1],
3155 tags => ['category:output'],
3156 },
3157  
3158 with_result_size => {
3159 summary => "Also return memory usage of each item code's result (return value)",
3160 schema => 'bool',
3161 description => <<'_',
3162  
3163 Memory size is measured using <pm:Devel::Size>.
3164  
3165 _
3166 },
3167  
3168 with_args_size => {
3169 summary => "Also return memory usage of item's arguments",
3170 schema => 'bool',
3171 description => <<'_',
3172  
3173 Memory size is measured using <pm:Devel::Size>.
3174  
3175 _
3176 },
3177  
3178 capture_stdout => {
3179 summary => 'Trap output to stdout',
3180 schema => 'bool',
3181 tags => ['category:output'],
3182 },
3183 capture_stderr => {
3184 summary => 'Trap output to stderr',
3185 schema => 'bool',
3186 tags => ['category:output'],
3187 },
3188  
3189 with_process_size => {
3190 summary => "Also return process size information for each item",
3191 schema => 'bool',
3192 description => <<'_',
3193  
3194 This is done by dumping each item's code into a temporary file and running the
3195 file with a new perl interpreter process and measuring the process size at the
3196 end (so it does not need to load Bencher itself or the other items). Currently
3197 only works on Linux because process size information is retrieved from
3198 `/proc/PID/smaps`. Not all code can work, e.g. if the code tries to access a
3199 closure or outside data or extra modules (modules not specified in the
3200 participant or loaded by the code itself). Usually does not make sense to use
3201 this on external command participants.
3202  
3203 _
3204 },
3205  
3206 return_meta => {
3207 summary => 'Whether to return extra metadata',
3208 description => <<'_',
3209  
3210 When set to true, will return extra metadata such as platform information, CPU
3211 information, system load before & after the benchmark, system time, and so on.
3212 This is put in result metadata under `func.*` keys.
3213  
3214 The default is to true (return extra metadata) unless when run as CLI and format
3215 is text (where the extra metadata is not shown).
3216  
3217 _
3218 schema => ['bool'],
3219 tags => ['category:output'],
3220 },
3221  
3222 save_result => {
3223 summary => 'Whether to save benchmark result to file',
3224 schema => 'bool*',
3225 description => <<'_',
3226  
3227 Will also be turned on automatically if `BENCHER_RESULT_DIR` environment
3228 variabl is defined.
3229  
3230 When this is turned on, will save a JSON file after benchmark, containing the
3231 result along with metadata. The directory of the JSON file will be determined
3232 from the `results_dir` option, while the filename from the `results_filename`
3233 option.
3234  
3235 _
3236 },
3237  
3238 result_dir => {
3239 summary => 'Directory to use when saving benchmark result',
3240 schema => 'dirname*',
3241 tags => ['category:output'],
3242 description => <<'_',
3243  
3244 Default is from `BENCHER_RESULT_DIR` environment variable, or the home
3245 directory.
3246  
3247 _
3248 },
3249 result_filename => {
3250 summary => 'Filename to use when saving benchmark result',
3251 schema => 'filename*',
3252 tags => ['category:output'],
3253 description => <<'_',
3254  
3255 Default is:
3256  
3257 <NAME>.<yyyy-dd-dd-"T"HH-MM-SS>.json
3258  
3259 or, when running in module startup mode:
3260  
3261 <NAME>.module_startup.<yyyy-dd-dd-"T"HH-MM-SS>.json
3262  
3263 or, when running in code startup mode:
3264  
3265 <NAME>.code_startup.<yyyy-dd-dd-"T"HH-MM-SS>.json
3266  
3267 where <NAME> is scenario module name, or `NO_MODULE` if scenario is not from a
3268 module. The `::` (double colon in the module name will be replaced with `-`
3269 (dash).
3270  
3271 _
3272 },
3273 render_as_benchmark_pm => {
3274 summary => 'Format result like Benchmark.pm',
3275 schema => 'true*',
3276 cmdline_aliases => {B=>{}},
3277 tags => ['category:output'],
3278 },
3279 note => {
3280 summary => 'Put additional note in the result',
3281 schema => ['str*'],
3282 tags => ['category:output'],
3283 },
3284 tidy => {
3285 summary => 'Run perltidy over generated scripts',
3286 schema => 'bool*',
3287 tags => ['category:debugging'],
3288 },
3289 keep_tempdir => {
3290 summary => 'Do not cleanup temporary directory when bencher ends',
3291 schema => 'bool*',
3292 tags => ['category:debugging'],
3293 },
3294 },
3295 };
3296 0 ▶sub bencher {
Subroutine bencher: not called CC=257 SCAR=110.6
Pod documented
3297 0 my %args = @_;
3298  
3299 0 my $action = $args{action};
3300 0 my $envres;
3301  
3302 my $is_cli_and_can_format_as_table;
3303 0 my $is_cli_and_text_format;
3304 {
3305 0 my $r = $args{-cmdline_r};
3306 $is_cli_and_can_format_as_table = $r &&
3307 0 ▶ ($r->{format} // 'text') =~ m!text|html!;
Condition0%0/5
$r && ($r->{'format'} // 'text') =~ /text|html/
!ll&&!rl&&r
000
$r->{"format"} // "text"
l!l
00
MC/DC0%0/2
$r && ($r->{'format'} // 'text') =~ /text|html/
$r $r->{"format"}
Truth table0%0/3
A && B
A= $rB= $r->{"format"}
ABresult
0X0
100
111
3308 $is_cli_and_text_format = $r &&
3309 0 ▶ ($r->{format} // 'text') =~ m!text!;
Condition0%0/5
$r && ($r->{'format'} // 'text') =~ /text/
!ll&&!rl&&r
000
$r->{"format"} // "text"
l!l
00
MC/DC0%0/2
$r && ($r->{'format'} // 'text') =~ /text/
$r $r->{"format"}
Truth table0%0/3
A && B
A= $rB= $r->{"format"}
ABresult
0X0
100
111
3310 }
3311  
3312 0 ▶ if ($action eq 'list-perls') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "list-perls") 0 0 0
3313 0 my @perls = _list_perls();
3314 0 my @res;
3315 0 for my $perl (@perls) {
3316 0 ▶ if ($args{detail}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'detail'}) { } 0 0 0
3317 push @res, {
3318 name => $perl->{name},
3319 version => $perl->{version},
3320 has_bencher => $perl->{has_bencher},
3321 bencher_version => $perl->{bencher_version},
3322 0 };
3323 } else {
3324 0 push @res, $perl->{name};
3325 }
3326 }
3327 0 my %resmeta;
3328 $resmeta{'table.fields'} = [
3329 'name',
3330 'version',
3331 'has_bencher',
3332 'bencher_version',
3333 0 ▶ ] if $args{detail};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"detail"} 0 0 0
3334 0 $envres =
3335 [200, "OK", \@res, \%resmeta];
3336 0 goto L_END;
3337 }
3338  
3339 0 ▶ if ($action eq 'list-scenario-modules') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "list-scenario-modules") 0 0 0
3340 0 require PERLANCAR::Module::List;
3341 0 local @INC = @INC;
3342 0 ▶ unshift @INC, $_ for @{ $args{include_path} // [] };
Condition0%0/2
$args{"include_path"} // []
l!l
00
MC/DC0%0/1
$args{"include_path"} // []
$args{"include_path"}
Truth table0%0/2
A
A= $args{"include_path"}
Aresult
11
00
3343 0 my $mods = PERLANCAR::Module::List::list_modules(
3344 'Bencher::Scenario::', {list_modules=>1, recurse=>1});
3345 $envres =
3346 [200, "OK",
3347 0 [map {(my $tmp = $_) =~ s/^Bencher::Scenario:://; $tmp} sort keys %$mods]];
3348 0 goto L_END;
3349 }
3350  
3351 0 my $unparsed = _get_scenario(parent_args=>\%args);
3352  
3353 0 ▶ if ($action eq 'show-scenario') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "show-scenario") 0 0 0
3354 0 $envres = [200, "OK", $unparsed];
3355 0 goto L_END;
3356 }
3357  
3358 0 my $stash = {};
3359  
3360 0 my $aibdf;
3361 0 ▶ $aibdf = 0 if $action =~ /\A(list-(datasets|participants))\z/;
Branch: 1 branch
BranchTrueFalseTotal
if $action =~ /\A(list-(datasets|participants))\z/ 0 0 0
3362  
3363 0 ▶ if ($unparsed->{before_parse_scenario}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($unparsed->{"before_parse_scenario"}) 0 0 0
3364 0 log_info("Executing before_parse_scenario hook ...");
3365 0 $unparsed->{before_parse_scenario}->(
3366 hook_name => 'before_parse_scenario',
3367 scenario => $unparsed,
3368 stash => $stash,
3369 );
3370 }
3371  
3372 0 my $parsed = _parse_scenario(
3373 scenario=>$unparsed,
3374 parent_args=>\%args,
3375 apply_include_by_default_filter => $aibdf,
3376 stash => $stash,
3377 );
3378  
3379 0 ▶ if ($parsed->{after_parse_scenario}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"after_parse_scenario"}) 0 0 0
3380 0 log_info("Executing after_parse_scenario hook ...");
3381 0 $parsed->{after_parse_scenario}->(
3382 hook_name => 'after_parse_scenario',
3383 scenario => $parsed,
3384 stash => $stash,
3385 );
3386 }
3387  
3388 0 ▶ my $module_startup = $args{module_startup} // $parsed->{module_startup};
Condition0%0/3
$args{"module_startup"} // $parsed->{"module_startup"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"module_startup"} // $parsed->{"module_startup"}
$args{"module_startup"} $parsed->{"module_startup"}
Truth table0%0/3
A // B
A= $args{"module_startup"}B= $parsed->{"module_startup"}
ABresult
1X1
011
000
3389 0 ▶ my $code_startup = $args{code_startup} // $parsed->{code_startup};
Condition0%0/3
$args{"code_startup"} // $parsed->{"code_startup"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"code_startup"} // $parsed->{"code_startup"}
$args{"code_startup"} $parsed->{"code_startup"}
Truth table0%0/3
A // B
A= $args{"code_startup"}B= $parsed->{"code_startup"}
ABresult
1X1
011
000
3390  
3391 # DEPRECATED/now undocumented, see before_parse_datasets for more
3392 # appropriate hook
3393 0 ▶ if ($parsed->{before_list_datasets}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_list_datasets"}) 0 0 0
3394 0 log_info("Executing before_list_datasets hook ...");
3395 0 $parsed->{before_list_datasets}->(
3396 hook_name => 'before_list_datasets',
3397 scenario => $parsed,
3398 stash => $stash,
3399 );
3400 }
3401  
3402 0 ▶ if ($action eq 'list-datasets') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "list-datasets") 0 0 0
3403 0 ▶ unless ($parsed->{datasets}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($parsed->{"datasets"}) 0 0 0
3404 0 $envres = [200, "OK", undef];
3405 0 goto L_END;
3406 }
3407 0 my @res;
3408 0 my $has_summary = 0;
3409 0 for my $ds (@{ $parsed->{datasets} }) {
3410 0 ▶ if ($args{detail}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'detail'}) { } 0 0 0
3411 my $rec = {
3412 seq => $ds->{seq},
3413 include_by_default => $ds->{include_by_default},
3414 name => $ds->{name},
3415 0 ▶ tags => join(", ", @{ $ds->{tags} // []}),
Condition0%0/2
$ds->{"tags"} // []
l!l
00
MC/DC0%0/1
$ds->{"tags"} // []
$ds->{"tags"}
Truth table0%0/2
A
A= $ds->{"tags"}
Aresult
11
00
3416 };
3417 0 ▶ if (defined $ds->{summary}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ds->{"summary"}) 0 0 0
3418 0 $has_summary = 1;
3419 0 $rec->{summary} = $ds->{summary};
3420 }
3421 0 push @res, $rec;
3422 } else {
3423 0 push @res, $ds->{name};
3424 }
3425 }
3426 0 my %resmeta;
3427 $resmeta{'table.fields'} = [
3428 'seq',
3429 'include_by_default',
3430 'name',
3431 ('summary') x $has_summary,
3432 'tags',
3433 ]
3434 0 ▶ if $args{detail};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"detail"} 0 0 0
3435 0 $envres = [200, "OK", \@res, \%resmeta];
3436 0 goto L_END;
3437 }
3438  
3439 # DEPRECATED/now undocumented, see before_parse_participants for more
3440 # appropriate hook
3441 0 ▶ if ($parsed->{before_list_participants}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_list_participants"}) 0 0 0
3442 0 log_info("Executing before_list_participants hook ...");
3443 0 $parsed->{before_list_participants}->(
3444 hook_name => 'before_list_participants',
3445 scenario => $parsed,
3446 stash => $stash,
3447 );
3448 }
3449  
3450 0 ▶ if ($action eq 'list-participant-modules') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "list-participant-modules") 0 0 0
3451 0 my @modules = _get_participant_modules($parsed);
3452 0 $envres = [200, "OK", \@modules];
3453 0 goto L_END;
3454 }
3455  
3456 0 ▶ if ($action eq 'list-participants') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "list-participants") 0 0 0
3457 0 my @res;
3458 0 my $has_summary = 0;
3459 0 for my $p (@{ $parsed->{participants} }) {
3460  
3461 0 my $cmdline;
3462 0 ▶ if ($p->{cmdline_template}) {
Branch: 4 branches
BranchTrueFalseTotal
if ($p->{'cmdline_template'}) { } 0 0 0
elsif ($p->{'cmdline'}) { } 0 0 0
elsif ($p->{'perl_cmdline_template'}) { } 0 0 0
elsif ($p->{'cmdline'}) { } 0 0 0
3463 $cmdline = "#TEMPLATE: ".
3464 0 ▶ (ref($p->{cmdline_template}) eq 'ARRAY' ? join(" ", @{$p->{cmdline_template}}) : $p->{cmdline_template});
Branch: 1 branch
BranchTrueFalseTotal
ref $p->{'cmdline_template'} eq 'ARRAY' ? : 0 0 0
3465 } elsif ($p->{cmdline}) {
3466 $cmdline =
3467 0 ▶ (ref($p->{cmdline}) eq 'ARRAY' ? join(" ", @{$p->{cmdline}}) : $p->{cmdline});
Branch: 1 branch
BranchTrueFalseTotal
ref $p->{'cmdline'} eq 'ARRAY' ? : 0 0 0
3468 } elsif ($p->{perl_cmdline_template}) {
3469 $cmdline = "#TEMPLATE: #perl ".
3470 0 ▶ (ref($p->{perl_cmdline_template}) eq 'ARRAY' ? join(" ", @{$p->{perl_cmdline_template}}) : $p->{perl_cmdline_template});
Branch: 1 branch
BranchTrueFalseTotal
ref $p->{'perl_cmdline_template'} eq 'ARRAY' ? : 0 0 0
3471 } elsif ($p->{cmdline}) {
3472 $cmdline = "#perl ".
3473 0 ▶ (ref($p->{perl_cmdline}) eq 'ARRAY' ? join(" ", @{$p->{perl_cmdline}}) : $p->{perl_cmdline});
Branch: 1 branch
BranchTrueFalseTotal
ref $p->{'perl_cmdline'} eq 'ARRAY' ? : 0 0 0
3474 }
3475 my $rec = {
3476 seq => $p->{seq},
3477 type => $p->{type},
3478 include_by_default => $p->{include_by_default},
3479 name => $p->{name} // $p->{_name},
3480 function => $p->{function},
3481 0 module => $p->{modules} ? join("+", @{$p->{modules}}) : $p->{module},
3482 cmdline => $cmdline,
3483 0 ▶ tags => join(", ", @{$p->{tags} // []}),
Branch: 1 branch
BranchTrueFalseTotal
$p->{'modules'} ? : 0 0 0
Condition0%0/5
$p->{"name"} // $p->{"_name"}
l!l&&r!l&&!r
000
$p->{"tags"} // []
l!l
00
MC/DC0%0/2
$p->{"name"} // $p->{"_name"}
$p->{"name"} $p->{"_name"}
MC/DC0%0/1
$p->{"tags"} // []
$p->{"tags"}
Truth table0%0/3
A // B
A= $p->{"name"}B= $p->{"_name"}
ABresult
1X1
011
000
Truth table0%0/2
A
A= $p->{"tags"}
Aresult
11
00
3484 };
3485 0 ▶ if (defined $p->{summary}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $p->{"summary"}) 0 0 0
3486 0 $has_summary = 1;
3487 0 $rec->{summary} = $p->{summary};
3488 }
3489 0 push @res, $rec;
3490 }
3491  
3492 0 ▶ unless ($args{detail}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"detail"}) 0 0 0
3493 0 @res = map {$_->{name}} @res;
3494 }
3495 0 my %resmeta;
3496 $resmeta{'table.fields'} = [
3497 'seq',
3498 'type',
3499 'include_by_default',
3500 'name',
3501 ('summary') x $has_summary,
3502 'module',
3503 'function',
3504 'cmdline',
3505 'tags',
3506 ]
3507 0 ▶ if $args{detail};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"detail"} 0 0 0
3508 0 $envres = [200, "OK", \@res, \%resmeta];
3509 0 goto L_END;
3510 }
3511  
3512 0 my $items;
3513 my $gen_items_res;
3514 GEN_ITEMS:
3515 {
3516 0 ▶ if ($parsed->{items}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"items"}) 0 0 0
3517 0 $items = $parsed->{items};
3518 0 last;
3519 }
3520 0 ▶ if ($parsed->{before_gen_items}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_gen_items"}) 0 0 0
3521 0 log_info("Executing before_gen_items hook ...");
3522 0 $parsed->{before_gen_items}->(
3523 hook_name => 'before_gen_items',
3524 scenario => $parsed,
3525 stash => $stash,
3526 );
3527 }
3528  
3529 0 $gen_items_res = _gen_items(scenario=>$parsed, parent_args=>\%args);
3530 0 ▶ unless ($gen_items_res->[0] == 200) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($gen_items_res->[0] == 200) 0 0 0
3531 0 $envres = $gen_items_res;
3532 0 goto L_END;
3533 }
3534 0 $items = $gen_items_res->[2];
3535 }
3536  
3537 0 ▶ if ($action eq 'list-items') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "list-items") 0 0 0
3538 0 my @rows;
3539 my @columns;
3540 0 for my $it0 (@$items) {
3541 0 my $it = {%$it0};
3542 0 for (grep {/^_/} keys %$it) {
3543 0 ▶ delete $it->{$_} unless /^_succinct_name/;
Branch: 1 branch
BranchTrueFalseTotal
unless /^_succinct_name/ 0 0 0
3544 }
3545 0 ▶ if (!@columns) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@columns) 0 0 0
3546 0 push @columns, sort keys %$it;
3547 }
3548 0 push @rows, $it;
3549 }
3550 0 ▶ unless ($args{detail}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($args{"detail"}) 0 0 0
3551 0 for (@rows) {
3552 0 $_ = $_->{seq};
3553 }
3554 }
3555 0 my %resmeta;
3556 0 ▶ $resmeta{'table.fields'} = \@columns if $args{detail};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"detail"} 0 0 0
3557 0 $envres = [200, "OK", \@rows, \%resmeta];
3558 0 goto L_END;
3559 }
3560  
3561 0 ▶ if ($action eq 'show-items-codes') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "show-items-codes") 0 0 0
3562 $envres = [200, "OK", join(
3563 "",
3564 0 map {(
3565 "#", _item_label(item=>$_, bencher_args=>\%args), ":\n",
3566 0 ▶ $_->{_code_str} // dmp($_->{_code}),
Condition0%0/3
$_->{"_code_str"} // dmp($_->{"_code"})
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{"_code_str"} // dmp($_->{"_code"})
$_->{"_code_str"} dmp($_->{"_code"})
Truth table0%0/3
A // B
A= $_->{"_code_str"}B= dmp($_->{"_code"})
ABresult
1X1
011
000
3567 "\n\n",
3568 )} @$items
3569 )];
3570 0 goto L_END;
3571 }
3572  
3573 0 ▶ if ($action eq 'dump-items') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "dump-items") 0 0 0
3574 0 ▶ if ($is_cli_and_text_format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cli_and_text_format) { } 0 0 0
3575 0 require Data::Dump;
3576 0 $envres = [200, "OK", Data::Dump::dump($items),
3577 {'cmdline.skip_format' => 1}];
3578 0 goto L_END;
3579 } else {
3580 0 $envres = [200, "OK", $items];
3581 }
3582 0 goto L_END;
3583 }
3584  
3585 0 ▶ if ($action eq 'dump-parsed-scenario') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "dump-parsed-scenario") 0 0 0
3586 0 ▶ if ($is_cli_and_text_format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cli_and_text_format) { } 0 0 0
3587 0 require Data::Dump;
3588 0 $envres = [200, "OK", Data::Dump::dump($parsed),
3589 {'cmdline.skip_format' => 1}];
3590 } else {
3591 0 $envres = [200, "OK", $parsed];
3592 }
3593 0 goto L_END;
3594 }
3595  
3596 0 ▶ if ($action eq 'profile') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "profile") 0 0 0
3597 0 require File::Temp;
3598 0 require Proc::ChildError;
3599 0 ▶ die "profile currently not yet supported on multiperl or multimodver\n" if $args{multiperl} || $args{multimodver};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"multiperl"} or $args{"multimodver"} 0 0 0
Condition0%0/3
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"multiperl"} or $args{"multimodver"}
$args{"multiperl"} $args{"multimodver"}
Truth table0%0/3
A or B
A= $args{"multiperl"}B= $args{"multimodver"}
ABresult
1X1
011
000
3600 0 my @res;
3601 0 my ($fh, $fname) = File::Temp::tempfile();
3602 0 for my $it (@$items) {
3603 # get participant's module & helper_modules
3604 0 my $participant;
3605 0 for my $p (@{ $parsed->{participants} }) {
3606 0 ▶ if ($p->{name} eq $it->{participant}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($p->{"name"} eq $it->{"participant"}) 0 0 0
3607 0 $participant = $p;
3608 0 last;
3609 }
3610 }
3611 0 my %mods;
3612 0 ▶ $mods{$participant->{module}}++ if $participant->{module};
Branch: 1 branch
BranchTrueFalseTotal
if $participant->{"module"} 0 0 0
3613 0 ▶ for (@{ $participant->{helper_modules} // [] }) {
Condition0%0/2
$participant->{"helper_modules"} // []
l!l
00
MC/DC0%0/1
$participant->{"helper_modules"} // []
$participant->{"helper_modules"}
Truth table0%0/2
A
A= $participant->{"helper_modules"}
Aresult
11
00
3614 0 $mods{$_}++;
3615 }
3616 0 my $code = $it->{_code_str};
3617 # unravel subroutine
3618 0 $code =~ s/.+?sub \{\s*//; $code =~ s/\}\s*\z//;
3619 # if start=no, activate profiler
3620 0 ▶ $code = "DB::enable_profile(); ".($args{precision} > 1 ? "for(1..$args{precision}) { $code }" : $code);;
Branch: 1 branch
BranchTrueFalseTotal
$args{'precision'} > 1 ? : 0 0 0
3621 my @cmd = (
3622 $^X,
3623 "-d:NYTProf",
3624 0 (map {"-m$_"} sort keys %mods),
3625 "-e",
3626 $code,
3627 );
3628 0 my $file = "$fname-nytprof$it->{seq}";
3629 0 local $ENV{NYTPROF} = "start=no:file=$file.out";
3630 #local $ENV{NYTPROF} = "file=$file.out";
3631 0 log_debug("Running command: %s ...", \@cmd);
3632 0 system @cmd;
3633 0 ▶ die "Failed running profiler for item #$it->{seq}: ".
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
3634 Proc::ChildError::explain_child_error()." (cmd=".
3635 join(" ", @cmd).")" if $?;
3636 0 @cmd = (
3637 "nytprofhtml",
3638 "-f", "$file.out",
3639 "-o", "$file.dir",
3640 );
3641 0 log_debug("Running command: %s ...", @cmd);
3642 0 system @cmd;
3643 0 ▶ die "Failed running profiler for item #$it->{seq}: ".
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
3644 Proc::ChildError::explain_child_error()." (cmd=".
3645 join(" ", @cmd).")" if $?;
3646 push @res, {
3647 seq => $it->{seq},
3648 dataset => $it->{dataset},
3649 participant => $it->{participant},
3650 0 profile_result_path => "$file.dir/index.html",
3651 };
3652 }
3653 0 ▶ if (@res == 1 && (-t STDOUT)) {
Branch: 1 branch
BranchTrueFalseTotal
if (@res == 1 and -t STDOUT) 0 0 0
Condition0%0/3
@res == 1 and -t STDOUT
!ll&&!rl&&r
000
MC/DC0%0/2
@res == 1 and -t STDOUT
@res == 1 -t STDOUT
Truth table0%0/3
A and B
A= @res == 1B= -t STDOUT
ABresult
0X0
100
111
3654 0 require Browser::Open;
3655 0 Browser::Open::open_browser($res[0]{profile_result_path});
3656 }
3657 0 $envres = [200, "OK", \@res, {
3658 'table.fields'=>[qw/seq dataset participant profile_result_path/],
3659 }];
3660 0 goto L_END;
3661 }
3662  
3663 0 ▶ if ($action =~ /\A(show-items-results-sizes|show-items-results|show-items-outputs|bench)\z/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($action =~ /\A(show-items-results-sizes|show-items-results|show-items-outputs|bench)\z/) 0 0 0
3664 0 require Capture::Tiny;
3665 0 require Module::Load;
3666 0 require Time::HiRes;
3667  
3668 0 my $participants = $parsed->{participants};
3669 0 my $datasets = $parsed->{datasets};
3670 0 $envres = [200, "OK", [], {}];
3671  
3672 0 $envres->[3]{'func.permute'} = $gen_items_res->[3]{'func.permute'};
3673  
3674 0 ▶ my $result_dir = $args{result_dir} // $ENV{BENCHER_RESULT_DIR};
Condition0%0/3
$args{"result_dir"} // $ENV{"BENCHER_RESULT_DIR"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"result_dir"} // $ENV{"BENCHER_RESULT_DIR"}
$args{"result_dir"} $ENV{"BENCHER_RESULT_DIR"}
Truth table0%0/3
A // B
A= $args{"result_dir"}B= $ENV{"BENCHER_RESULT_DIR"}
ABresult
1X1
011
000
3675 0 ▶ my $save_result = $args{save_result} // defined($result_dir);
Condition0%0/2
$args{"save_result"} // defined $result_dir
l!l
00
MC/DC0%0/1
$args{"save_result"} // defined $result_dir
$args{"save_result"}
Truth table0%0/2
A
A= $args{"save_result"}
Aresult
11
00
3676 0 ▶ $result_dir //= $ENV{HOME};
Condition0%0/3
$result_dir //= $ENV{"HOME"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$result_dir //= $ENV{"HOME"}
$result_dir $ENV{"HOME"}
Truth table0%0/3
A //= B
A= $result_dirB= $ENV{"HOME"}
ABresult
1X1
011
000
3677 0 ▶ my $return_meta = $args{return_meta} // ($save_result ? 1:undef) // 1;
Branch: 1 branch
BranchTrueFalseTotal
$save_result ? : 0 0 0
Condition0%0/4
($args{"return_meta"} // ($save_result ? 1 : undef)) // 1
l!l
00
$args{"return_meta"} // ($save_result ? 1 : undef)
l!l
00
MC/DC0%0/1
($args{"return_meta"} // ($save_result ? 1 : undef)) // 1
$args{"return_meta"}
Truth table0%0/2
A
A= $args{"return_meta"}
Aresult
11
00
3678 0 ▶ my $capture_stdout = $args{capture_stdout} // $parsed->{capture_stdout} // 0;
Condition0%0/5
($args{"capture_stdout"} // $parsed->{"capture_stdout"}) // 0
l!l
00
$args{"capture_stdout"} // $parsed->{"capture_stdout"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"capture_stdout"} // $parsed->{"capture_stdout"}) // 0
$args{"capture_stdout"} $parsed->{"capture_stdout"}
Truth table0%0/3
A // B
A= $args{"capture_stdout"}B= $parsed->{"capture_stdout"}
ABresult
1X1
011
000
3679 0 ▶ $capture_stdout = 1 if $action eq 'show-items-outputs';
Branch: 1 branch
BranchTrueFalseTotal
if $action eq "show-items-outputs" 0 0 0
3680 0 ▶ my $capture_stderr = $args{capture_stderr} // $parsed->{capture_stderr} // 0;
Condition0%0/5
($args{"capture_stderr"} // $parsed->{"capture_stderr"}) // 0
l!l
00
$args{"capture_stderr"} // $parsed->{"capture_stderr"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"capture_stderr"} // $parsed->{"capture_stderr"}) // 0
$args{"capture_stderr"} $parsed->{"capture_stderr"}
Truth table0%0/3
A // B
A= $args{"capture_stderr"}B= $parsed->{"capture_stderr"}
ABresult
1X1
011
000
3681 0 ▶ $capture_stderr = 1 if $action eq 'show-items-outputs';
Branch: 1 branch
BranchTrueFalseTotal
if $action eq "show-items-outputs" 0 0 0
3682  
3683 0 $envres->[3]{'func.module_startup'} = $module_startup;
3684 0 $envres->[3]{'func.code_startup'} = $code_startup;
3685 0 ▶ $envres->[3]{'func.module_versions'}{perl} = "$^V" if $return_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $return_meta 0 0 0
3686 {
3687 0 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.2
3688 0 ▶ $envres->[3]{'func.module_versions'}{__PACKAGE__} = ${__PACKAGE__.'::VERSION'} if $return_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $return_meta 0 0 0
3689 }
3690  
3691 0 ▶ my $code_load = sub {
Subroutine __ANON__: not called CC=3 SCAR=21.1
3692 3 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
3693 0 my ($mod, $optional) = @_;
3694 0 log_trace("Loading module: %s", $mod);
3695 0 ▶ if ($optional) {
Branch: 1 branch
BranchTrueFalseTotal
if ($optional) { } 0 0 0
3696 0 eval { Module::Load::load($mod) };
3697 0 log_info("Failed loading optional module %s: %s, skipped",
3698 $mod, $@);
3699 0 return;
3700 } else {
3701 0 Module::Load::load($mod);
3702 }
3703 0 ▶ if ($return_meta) {
Branch: 1 branch
BranchTrueFalseTotal
if ($return_meta) 0 0 0
3704 # we'll just use ${"$mod\::VERSION"} because we are already
3705 # loading the module
3706 $envres->[3]{'func.module_versions'}{$mod} =
3707 0 ${"$mod\::VERSION"};
3708 }
3709 0 };
3710  
3711 0 ▶ my $runner = $args{runner} // $parsed->{runner} // 'Benchmark::Dumb';
Condition0%0/5
($args{"runner"} // $parsed->{"runner"}) // "Benchmark::Dumb"
l!l
00
$args{"runner"} // $parsed->{"runner"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"runner"} // $parsed->{"runner"}) // "Benchmark::Dumb"
$args{"runner"} $parsed->{"runner"}
Truth table0%0/3
A // B
A= $args{"runner"}B= $parsed->{"runner"}
ABresult
1X1
011
000
3712 0 $code_load->($runner);
3713  
3714 0 ▶ $code_load->('Devel::Platform::Info') if $return_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $return_meta 0 0 0
3715 0 ▶ $code_load->('Sys::Info') if $return_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $return_meta 0 0 0
3716 0 ▶ $code_load->('Sys::Load', 'optional') if $return_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $return_meta 0 0 0
3717  
3718 # load all participant modules & helper modules
3719 {
3720 0 my %seen;
3721 0 my @modules = _get_participant_modules($parsed);
3722 0 my @helper_modules = _get_participant_helper_modules($parsed);
3723 0 for my $mod (@modules, @helper_modules) {
3724 0 $code_load->($mod);
3725 }
3726 0 for my $mod (keys %{$parsed->{modules}}) {
3727 0 ▶ next if $mod eq 'perl';
Branch: 1 branch
BranchTrueFalseTotal
if $mod eq "perl" 0 0 0
3728 0 $code_load->($mod);
3729 }
3730 }
3731  
3732 # loading extra modules
3733 0 ▶ $code_load->($_) for @{ $parsed->{extra_modules} // [] };
Condition0%0/2
$parsed->{"extra_modules"} // []
l!l
00
MC/DC0%0/1
$parsed->{"extra_modules"} // []
$parsed->{"extra_modules"}
Truth table0%0/2
A
A= $parsed->{"extra_modules"}
Aresult
11
00
3734  
3735 0 ▶ if ($parsed->{before_bench}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_bench"}) 0 0 0
3736 0 log_info("Executing before_bench hook ...");
3737 0 $parsed->{before_bench}->(
3738 hook_name => 'before_bench',
3739 scenario => $parsed,
3740 stash => $stash,
3741 );
3742 }
3743  
3744 my $with_process_size = $args{with_process_size} //
3745 0 ▶ $parsed->{with_process_size};
Condition0%0/3
$args{"with_process_size"} // $parsed->{"with_process_size"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"with_process_size"} // $parsed->{"with_process_size"}
$args{"with_process_size"} $parsed->{"with_process_size"}
Truth table0%0/3
A // B
A= $args{"with_process_size"}B= $parsed->{"with_process_size"}
ABresult
1X1
011
000
3746  
3747 # test code first
3748 0 ▶ my $test = $args{test} // $parsed->{test} // 1;
Condition0%0/5
($args{"test"} // $parsed->{"test"}) // 1
l!l
00
$args{"test"} // $parsed->{"test"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"test"} // $parsed->{"test"}) // 1
$args{"test"} $parsed->{"test"}
Truth table0%0/3
A // B
A= $args{"test"}B= $parsed->{"test"}
ABresult
1X1
011
000
3749 0 ▶ my $on_failure = $args{on_failure} // $parsed->{on_failure} // 'die';
Condition0%0/5
($args{"on_failure"} // $parsed->{"on_failure"}) // "die"
l!l
00
$args{"on_failure"} // $parsed->{"on_failure"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"on_failure"} // $parsed->{"on_failure"}) // "die"
$args{"on_failure"} $parsed->{"on_failure"}
Truth table0%0/3
A // B
A= $args{"on_failure"}B= $parsed->{"on_failure"}
ABresult
1X1
011
000
3750 my $on_result_failure = $args{on_result_failure} //
3751 0 ▶ $parsed->{on_result_failure} // $on_failure;
Condition0%0/6
($args{"on_result_failure"} // $parsed->{"on_result_failure"}) // $on_failure
l!l&&r!l&&!r
000
$args{"on_result_failure"} // $parsed->{"on_result_failure"}
l!l&&r!l&&!r
000
MC/DC0%0/3
($args{"on_result_failure"} // $parsed->{"on_result_failure"}) // $on_failure
$args{"on_result_failure"} $parsed->{"on_result_failure"} $on_failure
Truth table0%0/4
A // B // C
A= $args{"on_result_failure"}B= $parsed->{"on_result_failure"}C= $on_failure
ABCresult
1XX1
01X1
0011
0000
3752 my $with_args_size = $args{with_args_size} //
3753 0 ▶ $parsed->{with_args_size} // 0;
Condition0%0/5
($args{"with_args_size"} // $parsed->{"with_args_size"}) // 0
l!l
00
$args{"with_args_size"} // $parsed->{"with_args_size"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"with_args_size"} // $parsed->{"with_args_size"}) // 0
$args{"with_args_size"} $parsed->{"with_args_size"}
Truth table0%0/3
A // B
A= $args{"with_args_size"}B= $parsed->{"with_args_size"}
ABresult
1X1
011
000
3754 my $with_result_size = $args{with_result_size} //
3755 0 ▶ $parsed->{with_result_size} // 0;
Condition0%0/5
($args{"with_result_size"} // $parsed->{"with_result_size"}) // 0
l!l
00
$args{"with_result_size"} // $parsed->{"with_result_size"}
l!l&&r!l&&!r
000
MC/DC0%0/2
($args{"with_result_size"} // $parsed->{"with_result_size"}) // 0
$args{"with_result_size"} $parsed->{"with_result_size"}
Truth table0%0/3
A // B
A= $args{"with_result_size"}B= $parsed->{"with_result_size"}
ABresult
1X1
011
000
3756 0 ▶ $with_args_size = 0 if $module_startup || $code_startup;
Branch: 1 branch
BranchTrueFalseTotal
if $module_startup or $code_startup 0 0 0
Condition0%0/3
$module_startup or $code_startup
l!l&&r!l&&!r
000
MC/DC0%0/2
$module_startup or $code_startup
$module_startup $code_startup
Truth table0%0/3
A or B
A= $module_startupB= $code_startup
ABresult
1X1
011
000
3757 0 ▶ $with_result_size = 1 if $action eq 'show-items-results-sizes';
Branch: 1 branch
BranchTrueFalseTotal
if $action eq "show-items-results-sizes" 0 0 0
3758 0 ▶ $with_result_size = 0 if $module_startup || $code_startup;
Branch: 1 branch
BranchTrueFalseTotal
if $module_startup or $code_startup 0 0 0
Condition0%0/3
$module_startup or $code_startup
l!l&&r!l&&!r
000
MC/DC0%0/2
$module_startup or $code_startup
$module_startup $code_startup
Truth table0%0/3
A or B
A= $module_startupB= $code_startup
ABresult
1X1
011
000
3759 {
3760 0 ▶ last if $args{multiperl} || $args{multimodver} || !$test;
Branch: 1 branch
BranchTrueFalseTotal
if $args{"multiperl"} or $args{"multimodver"} or not $test 0 0 0
Condition0%0/6
$args{"multiperl"} or $args{"multimodver"} or not $test
l!l&&r!l&&!r
000
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$args{"multiperl"} or $args{"multimodver"} or not $test
$args{"multiperl"} $args{"multimodver"} not $test
Truth table0%0/4
A or B or not(C)
A= $args{"multiperl"}B= $args{"multimodver"}C= not $test
ABCresult
1XX1
01X1
0011
0000
3761 0 my $fitems = [];
3762 0 for my $it (@$items) {
3763 0 ▶ if ($parsed->{before_test_item}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_test_item"}) 0 0 0
3764 0 $parsed->{before_test_item}->(
3765 hook_name => 'before_test_item',
3766 scenario => $parsed,
3767 stash => $stash,
3768 item => $it,
3769 );
3770 }
3771 log_trace("Testing code for item #%d (%s) ...",
3772 0 $it->{seq}, $it->{_name});
3773  
3774 0 my $participant = _find_record_by_seq($participants, $it->{_permute}{participant});
3775  
3776 # scenario was from a dump (_code removed). we reconstruct code
3777 # from _code_str
3778 0 ▶ if (!$it->{_code}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($it->{"_code"}) 0 0 0
3779 0 ▶ if (defined $it->{_code_str}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $it->{'_code_str'}) { } 0 0 0
3780 0 $it->{_code} = eval $it->{_code_str}; ## no critic: BuiltinFunctions::ProhibitStringyEval
3781 0 ▶ die "Can't compile _code_str '$it->{_code_str}': $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
3782 } else {
3783 0 die "BUG: Item doesn't have _code or _code_str";
3784 }
3785 }
3786  
3787 0 eval {
3788 0 ▶ my $result_is_list = $participant->{result_is_list} // 0;
Condition0%0/2
$participant->{"result_is_list"} // 0
l!l
00
MC/DC0%0/1
$participant->{"result_is_list"} // 0
$participant->{"result_is_list"}
Truth table0%0/2
A
A= $participant->{"result_is_list"}
Aresult
11
00
3789 0 ▶ if ($capture_stdout && $capture_stderr) {
Branch: 3 branches
BranchTrueFalseTotal
if ($capture_stdout and $capture_stderr) { } 0 0 0
elsif ($capture_stdout) { } 0 0 0
elsif ($capture_stderr) { } 0 0 0
Condition0%0/3
$capture_stdout and $capture_stderr
!ll&&!rl&&r
000
MC/DC0%0/2
$capture_stdout and $capture_stderr
$capture_stdout $capture_stderr
Truth table0%0/3
A and B
A= $capture_stdoutB= $capture_stderr
ABresult
0X0
100
111
3790 0 my ($stdout, $stderr, @res) = &Capture::Tiny::capture($it->{_code});
3791 0 $it->{_stdout} = $stdout;
3792 0 $it->{_stderr} = $stderr;
3793 0 ▶ $it->{_result} = $result_is_list ? \@res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
$result_is_list ? : 0 0 0
3794 } elsif ($capture_stdout) {
3795 0 my ($stdout, @res) = &Capture::Tiny::capture_stdout($it->{_code});
3796 0 $it->{_stdout} = $stdout;
3797 0 ▶ $it->{_result} = $result_is_list ? \@res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
$result_is_list ? : 0 0 0
3798 } elsif ($capture_stderr) {
3799 0 my ($stderr, @res) = &Capture::Tiny::capture_stderr($it->{_code});
3800 0 $it->{_stderr} = $stderr;
3801 0 ▶ $it->{_result} = $result_is_list ? \@res : $res[0];
Branch: 1 branch
BranchTrueFalseTotal
$result_is_list ? : 0 0 0
3802 } else {
3803 $it->{_result} = $result_is_list ?
3804 0 ▶ [$it->{_code}->()] : $it->{_code}->();
Branch: 1 branch
BranchTrueFalseTotal
$result_is_list ? : 0 0 0
3805 }
3806 };
3807 0 my $err = $@;
3808  
3809 0 ▶ if ($parsed->{after_test_item}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"after_test_item"}) 0 0 0
3810 0 $err = $parsed->{after_test_item}->(
3811 hook_name => 'after_test_item',
3812 scenario => $parsed,
3813 stash => $stash,
3814 item => $it,
3815 );
3816 }
3817  
3818 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
3819 0 ▶ if ($on_failure eq 'skip' || $action eq 'show-items-results') {
Branch: 1 branch
BranchTrueFalseTotal
if ($on_failure eq 'skip' or $action eq 'show-items-results') { } 0 0 0
Condition0%0/3
$on_failure eq "skip" or $action eq "show-items-results"
l!l&&r!l&&!r
000
MC/DC0%0/2
$on_failure eq "skip" or $action eq "show-items-results"
$on_failure eq "skip" $action eq "show-items-results"
Truth table0%0/3
A or B
A= $on_failure eq "skip"B= $action eq "show-items-results"
ABresult
1X1
011
000
3820 0 warn "Skipping item #$it->{seq} ($it->{_name}) ".
3821 "due to failure: $err\n";
3822 0 next;
3823 } else {
3824 0 die "Item #$it->{seq} ($it->{_name}) fails: $err\n";
3825 }
3826 }
3827  
3828 0 $err = "";
3829 # check against expected result, if specified
3830 {
3831 0 my $dmp_exp_result;
3832 0 ▶ if (exists $it->{_permute}{dataset}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $it->{"_permute"}{"dataset"}) 0 0 0
3833 0 my $dataset = _find_record_by_seq($datasets, $it->{_permute}{dataset});
3834 0 ▶ if (exists $dataset->{result}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $dataset->{"result"}) 0 0 0
3835 0 $dmp_exp_result = dmp($dataset->{result});
3836 0 goto CHK;
3837 }
3838 }
3839 0 ▶ if (exists $parsed->{result}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $parsed->{"result"}) 0 0 0
3840 0 $dmp_exp_result = dmp($parsed->{result});
3841 0 goto CHK;
3842 }
3843 0 last;
3844 CHK:
3845 0 my $dmp_result = dmp($it->{_result});
3846 0 ▶ if ($dmp_result ne $dmp_exp_result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($dmp_result ne $dmp_exp_result) 0 0 0
3847 0 $err = "Result ($dmp_result) is not as expected ($dmp_exp_result)";
3848 }
3849 }
3850  
3851 0 ▶ if ($err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($err) 0 0 0
3852 0 ▶ if ($on_result_failure eq 'skip') {
Branch: 2 branches
BranchTrueFalseTotal
if ($on_result_failure eq 'skip') { } 0 0 0
elsif ($on_result_failure eq 'warn' or $action eq 'show-items-results') { } 0 0 0
3853 0 warn "Skipping item #$it->{seq} ($it->{_name}) ".
3854 "due to failure (2): $err\n";
3855 0 next;
3856 ▶ } elsif ($on_result_failure eq 'warn' || $action eq 'show-items-results') {
Condition0%0/3
$on_result_failure eq "warn" or $action eq "show-items-results"
l!l&&r!l&&!r
000
MC/DC0%0/2
$on_result_failure eq "warn" or $action eq "show-items-results"
$on_result_failure eq "warn" $action eq "show-items-results"
Truth table0%0/3
A or B
A= $on_result_failure eq "warn"B= $action eq "show-items-results"
ABresult
1X1
011
000
3857 0 warn "Warning: item #$it->{seq} ($it->{_name}) ".
3858 "has failure (2): $err\n";
3859 } else {
3860 0 die "Item #$it->{seq} ($it->{_name}) fails (2): $err\n";
3861 }
3862 }
3863 0 $it->{_code_error} = $err;
3864  
3865 {
3866 0 ▶ last unless $with_args_size;
Branch: 1 branch
BranchTrueFalseTotal
unless $with_args_size 0 0 0
3867 0 ▶ last unless $it->{_template_vars};
Branch: 1 branch
BranchTrueFalseTotal
unless $it->{"_template_vars"} 0 0 0
3868 0 require Devel::Size;
3869 0 for my $arg (keys %{ $it->{_template_vars} }) {
3870 $it->{_arg_sizes}{$arg} = Devel::Size::total_size(
3871 0 $it->{_template_vars}{$arg});
3872 }
3873 }
3874  
3875 0 ▶ if ($with_result_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_result_size) 0 0 0
3876 0 require Devel::Size;
3877 0 $it->{_result_size} = Devel::Size::total_size($it->{_result});
3878 }
3879  
3880 0 ▶ if ($with_process_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_process_size) 0 0 0
3881 0 _get_process_size(\%args, $parsed, $it);
3882 }
3883  
3884 0 push @$fitems, $it;
3885 }
3886 0 $items = $fitems;
3887 }
3888  
3889 0 ▶ if ($action eq 'show-items-results') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "show-items-results") 0 0 0
3890 0 ▶ die "show-items-results currently not supported on multiperl or multimodver\n" if $args{multiperl} || $args{multimodver};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"multiperl"} or $args{"multimodver"} 0 0 0
Condition0%0/3
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"multiperl"} or $args{"multimodver"}
$args{"multiperl"} $args{"multimodver"}
Truth table0%0/3
A or B
A= $args{"multiperl"}B= $args{"multimodver"}
ABresult
1X1
011
000
3891 0 ▶ if ($is_cli_and_text_format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cli_and_text_format) { } 0 0 0
3892 0 require Data::Dump;
3893 0 $envres->[3]{'cmdline.skip_format'} = 1;
3894 $envres->[2] = join(
3895 "",
3896 0 map {(
3897 "#", _item_label(item=>$_, bencher_args=>\%args), ":\n",
3898 0 ▶ $args{raw} ? $_->{_result} : Data::Dump::dump($_->{_result}),
Branch: 1 branch
BranchTrueFalseTotal
$args{'raw'} ? : 0 0 0
3899 "\n\n",
3900 )} @$items
3901 );
3902 } else {
3903 0 $envres->[2] = [map {$_->{_result}} @$items];
3904 }
3905 0 goto RETURN_RESULT;
3906 }
3907  
3908 0 ▶ if ($action eq 'show-items-results-sizes') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "show-items-results-sizes") 0 0 0
3909 0 ▶ die "show-items-results currently not supported on multiperl or multimodver\n" if $args{multiperl} || $args{multimodver};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"multiperl"} or $args{"multimodver"} 0 0 0
Condition0%0/3
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"multiperl"} or $args{"multimodver"}
$args{"multiperl"} $args{"multimodver"}
Truth table0%0/3
A or B
A= $args{"multiperl"}B= $args{"multimodver"}
ABresult
1X1
011
000
3910 0 ▶ if ($is_cli_and_text_format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cli_and_text_format) { } 0 0 0
3911 0 $envres->[3]{'cmdline.skip_format'} = 1;
3912 $envres->[2] = join(
3913 "",
3914 0 map {(
3915 "#", _item_label(item=>$_, bencher_args=>\%args), ":\n",
3916 $_->{_result_size},
3917 0 "\n\n",
3918 )} @$items
3919 );
3920 } else {
3921 0 $envres->[2] = [map {$_->{_result_size}} @$items];
3922 }
3923 0 goto RETURN_RESULT;
3924 }
3925  
3926 0 ▶ if ($action eq 'show-items-outputs') {
Branch: 1 branch
BranchTrueFalseTotal
if ($action eq "show-items-outputs") 0 0 0
3927 0 ▶ die "show-items-outputs currently not supported on multiperl or multimodver\n" if $args{multiperl} || $args{multimodver};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"multiperl"} or $args{"multimodver"} 0 0 0
Condition0%0/3
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"multiperl"} or $args{"multimodver"}
$args{"multiperl"} $args{"multimodver"}
Truth table0%0/3
A or B
A= $args{"multiperl"}B= $args{"multimodver"}
ABresult
1X1
011
000
3928 0 ▶ if ($is_cli_and_text_format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cli_and_text_format) { } 0 0 0
3929 0 $envres->[3]{'cmdline.skip_format'} = 1;
3930 $envres->[2] = join(
3931 "",
3932 0 map {(
3933 "#", _item_label(item=>$_, bencher_args=>\%args), " stdout (", length($_->{_stdout} // ''), " bytes):\n",
3934 ($_->{_stdout} // ''),
3935 "\n\n",
3936 "#", _item_label(item=>$_, bencher_args=>\%args), " stderr (", length($_->{_stderr} // ''), " bytes):\n",
3937 0 ▶ ($_->{_stderr} // ''),
Condition0%0/8
$_->{"_stdout"} // ""
l!l
00
$_->{"_stdout"} // ""
l!l
00
$_->{"_stderr"} // ""
l!l
00
$_->{"_stderr"} // ""
l!l
00
MC/DC0%0/1
$_->{"_stdout"} // ""
$_->{"_stdout"}
MC/DC0%0/1
$_->{"_stdout"} // ""
$_->{"_stdout"}
MC/DC0%0/1
$_->{"_stderr"} // ""
$_->{"_stderr"}
MC/DC0%0/1
$_->{"_stderr"} // ""
$_->{"_stderr"}
Truth table0%0/2
A
A= $_->{"_stdout"}
Aresult
11
00
Truth table0%0/2
A
A= $_->{"_stdout"}
Aresult
11
00
Truth table0%0/2
A
A= $_->{"_stderr"}
Aresult
11
00
Truth table0%0/2
A
A= $_->{"_stderr"}
Aresult
11
00
3938 "\n\n",
3939 )} @$items
3940 );
3941 } else {
3942 0 $envres->[2] = [map {$_->{_result_size}} @$items];
3943 }
3944 0 goto RETURN_RESULT;
3945 }
3946  
3947 # at this point, action = bench
3948  
3949 0 my $precision;
3950 0 ▶ if ($runner eq 'Benchmark') {
Branch: 2 branches
BranchTrueFalseTotal
if ($runner eq 'Benchmark') { } 0 0 0
elsif ($runner eq 'Benchmark::Dumb::SimpleTime') { } 0 0 0
3951 0 ▶ $precision = $args{precision} // -0.5;
Condition0%0/2
$args{"precision"} // "-0.5"
l!l
00
MC/DC0%0/1
$args{"precision"} // "-0.5"
$args{"precision"}
Truth table0%0/2
A
A= $args{"precision"}
Aresult
11
00
3952 0 ▶ if (defined $args{precision_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"precision_limit"}) 0 0 0
3953 0 ▶ if ($precision < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($precision < 0) { } 0 0 0
3954 0 ▶ if ($precision < $args{precision_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($precision < $args{"precision_limit"}) 0 0 0
3955 0 $precision = $args{precision_limit};
3956 }
3957 } else {
3958 0 ▶ if ($precision > $args{precision_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > $args{"precision_limit"}) 0 0 0
3959 0 $precision = $args{precision_limit};
3960 }
3961 }
3962 }
3963 } elsif ($runner eq 'Benchmark::Dumb::SimpleTime') {
3964 0 ▶ $precision = $args{precision} // 1;
Condition0%0/2
$args{"precision"} // 1
l!l
00
MC/DC0%0/1
$args{"precision"} // 1
$args{"precision"}
Truth table0%0/2
A
A= $args{"precision"}
Aresult
11
00
3965 0 ▶ return [400, "When running with runner '$runner', precision must be an integer >= 1"]
Branch: 1 branch
BranchTrueFalseTotal
unless $precision =~ /\A[1-9][0-9]*\z/ 0 0 0
3966 unless $precision =~ /\A[1-9][0-9]*\z/;
3967 0 ▶ if (defined $args{precision_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"precision_limit"}) 0 0 0
3968 return [400, "When running with runner '$runner', precision_limit must be an integer >= 1"]
3969 0 ▶ unless $args{precision_limit} =~ /\A[1-9][0-9]*\z/;
Branch: 1 branch
BranchTrueFalseTotal
unless $args{"precision_limit"} =~ /\A[1-9][0-9]*\z/ 0 0 0
3970 0 ▶ if ($precision > $args{precision_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($precision > $args{"precision_limit"}) 0 0 0
3971 0 $precision = $args{precision_limit};
3972 }
3973 }
3974 } else {
3975 $precision = $args{precision} //
3976 ($module_startup ? $parsed->{module_startup_precision} : undef) //
3977 0 ▶ $parsed->{precision} // $parsed->{default_precision} // 0;
Branch: 1 branch
BranchTrueFalseTotal
$module_startup ? : 0 0 0
Condition0%0/11
((($args{"precision"} // ($module_startup ? $parsed->{"module_startup_precision"} : undef)) // $parsed->{"precision"}) // $parsed->{"default_precision"}) // 0
l!l
00
(($args{"precision"} // ($module_startup ? $parsed->{"module_startup_precision"} : undef)) // $parsed->{"precision"}) // $parsed->{"default_precision"}
l!l&&r!l&&!r
000
($args{"precision"} // ($module_startup ? $parsed->{"module_startup_precision"} : undef)) // $parsed->{"precision"}
l!l&&r!l&&!r
000
$args{"precision"} // ($module_startup ? $parsed->{"module_startup_precision"} : undef)
l!l&&r!l&&!r
000
MC/DC0%0/4
((($args{"precision"} // ($module_startup ? $parsed->{"module_startup_precision"} : undef)) // $parsed->{"precision"}) // $parsed->{"default_precision"}) // 0
$args{"precision"} ($module_startup ? $parsed->{"module_startup_precision"} : undef) $parsed->{"precision"} $parsed->{"default_precision"}
Truth table0%0/5
A // B // C // D
A= $args{"precision"}B= ($module_startup ? $parsed->{"module_startup_precision"} : undef)C= $parsed->{"precision"}D= $parsed->{"default_precision"}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
3978 0 ▶ if (defined($args{precision_limit}) && $precision < $args{precision_limit}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"precision_limit"} and $precision < $args{"precision_limit"}) 0 0 0
Condition0%0/3
defined $args{"precision_limit"} and $precision < $args{"precision_limit"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $args{"precision_limit"} and $precision < $args{"precision_limit"}
defined $args{"precision_limit"} $precision < $args{"precision_limit"}
Truth table0%0/3
A and B
A= defined $args{"precision_limit"}B= $precision < $args{"precision_limit"}
ABresult
0X0
100
111
3979 0 $precision = $args{precision_limit};
3980 }
3981 }
3982  
3983 0 ▶ if ($runner eq 'Benchmark') {
Branch: 1 branch
BranchTrueFalseTotal
if ($runner eq "Benchmark") 0 0 0
3984 0 ▶ die "Bench with Benchmark.pm currently does not support on multiperl or multimodver\n" if $args{multiperl} || $args{multimodver};
Branch: 1 branch
BranchTrueFalseTotal
if $args{"multiperl"} or $args{"multimodver"} 0 0 0
Condition0%0/3
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"multiperl"} or $args{"multimodver"}
$args{"multiperl"} $args{"multimodver"}
Truth table0%0/3
A or B
A= $args{"multiperl"}B= $args{"multimodver"}
ABresult
1X1
011
000
3985 0 my %codes;
3986 my %legends;
3987 0 for my $it (@$items) {
3988 0 my $key = $it->{_succinct_name};
3989 0 ▶ if (!length($key)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (length $key) 0 0 0
3990 0 $key = $it->{seq};
3991 }
3992 0 ▶ if (exists $codes{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $codes{$key}) 0 0 0
3993 0 $key .= " #$it->{seq}";
3994 }
3995 0 $codes{$key} = $it->{_code};
3996 $legends{$key} = join(
3997 0 " ", map {"$_=$it->{$_}"}
3998 0 grep { !/^_/ }
3999 sort keys %$it
4000 );
4001 }
4002 0 log_trace "Running benchmark with Benchmark.pm ...";
4003 my ($stdout, @res) = &Capture::Tiny::capture_stdout(
4004 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
4005 0 Benchmark::cmpthese($precision, \%codes);
4006 0 print "\n";
4007 0 print "Legends:\n";
4008 0 for (sort keys %legends) {
4009 0 print " ", $_, ": ", $legends{$_}, "\n";
4010 }
4011 0 });
4012 0 $envres->[3]{'cmdline.skip_format'} = 1;
4013 0 $envres->[2] = $stdout;
4014 0 goto RETURN_RESULT;
4015 }
4016  
4017 0 my $time_start = Time::HiRes::time();
4018 0 ▶ if ($return_meta) {
Branch: 1 branch
BranchTrueFalseTotal
if ($return_meta) 0 0 0
4019 0 $envres->[3]{'func.bencher_version'} = $Bencher::VERSION;
4020 $envres->[3]{'func.bencher_args'} = {
4021 0 map {$_=>$args{$_}} grep {!/\A-/} keys %args};
4022 0 ▶ if ($args{scenario_file}) {
Branch: 3 branches
BranchTrueFalseTotal
if ($args{'scenario_file'}) { } 0 0 0
elsif (my $mod = $args{'scenario_module'}) { } 0 0 0
elsif (my $mod0 = $args{'cpanmodules_module'}) { } 0 0 0
4023 0 $envres->[3]{'func.scenario_file'} = $args{scenario_file};
4024 0 my @st = stat($args{scenario_file});
4025 0 $envres->[3]{'func.scenario_file_mtime'} = $st[9];
4026 0 my $digests = _digest($args{scenario_file});
4027 0 $envres->[3]{'func.scenario_file_md5sum'} = $digests->{md5};
4028 0 $envres->[3]{'func.scenario_file_sha1sum'} = $digests->{sha1};
4029 0 $envres->[3]{'func.scenario_file_sha256sum'} = $digests->{sha256};
4030 } elsif (my $mod = $args{scenario_module}) {
4031 3 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
4032 0 ▶ $mod = "Bencher::Scenario::$mod" unless $mod =~ /\ABencher::Scenario::/;
Branch: 1 branch
BranchTrueFalseTotal
unless $mod =~ /\ABencher::Scenario::/ 0 0 0
4033 0 $envres->[3]{'func.scenario_module'} = $mod;
4034 0 (my $mod_pm = "$mod.pm") =~ s!::!/!g;
4035 0 ▶ $INC{$mod_pm} or die "BUG: Can't find '$mod_pm' in \%INC";
Branch: 1 branch
BranchTrueFalseTotal
$INC{$mod_pm} or die "BUG: Can't find '${mod_pm}' in %INC" 0 0 0
4036 0 my @st = stat($INC{$mod_pm});
4037 0 $envres->[3]{'func.scenario_module_mtime'} = $st[9];
4038 0 my $digests = _digest($INC{$mod_pm});
4039 0 $envres->[3]{'func.scenario_module_md5sum'} = $digests->{md5};
4040 0 $envres->[3]{'func.scenario_module_sha1sum'} = $digests->{sha1};
4041 0 $envres->[3]{'func.scenario_module_sha256sum'} = $digests->{sha256};
4042 $envres->[3]{'func.module_versions'}{$mod} =
4043 0 ${"$mod\::VERSION"};
4044 } elsif (my $mod0 = $args{cpanmodules_module}) {
4045 3 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
4046 0 my $mod = "Acme::CPANModules::$mod0";
4047 0 $envres->[3]{'func.cpanmodules_module'} = $mod;
4048 0 (my $mod_pm = "$mod.pm") =~ s!::!/!g;
4049 0 my @st = stat($INC{$mod_pm});
4050 0 $envres->[3]{'func.cpanmodules_module_mtime'} = $st[9];
4051 0 my $digests = _digest($INC{$mod_pm});
4052 0 $envres->[3]{'func.cpanmodules_module_md5sum'} = $digests->{md5};
4053 0 $envres->[3]{'func.cpanmodules_module_sha1sum'} = $digests->{sha1};
4054 0 $envres->[3]{'func.cpanmodules_module_sha256sum'} = $digests->{sha256};
4055 $envres->[3]{'func.module_versions'}{$mod} =
4056 0 ${"$mod\::VERSION"};
4057 }
4058 $envres->[3]{'func.sysload_before'} = [Sys::Load::getload()]
4059 0 ▶ if $INC{"System/Load.pm"};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"System/Load.pm"} 0 0 0
4060 0 $envres->[3]{'func.time_start'} = $time_start;
4061 }
4062  
4063 0 ▶ $envres->[3]{'func.precision'} = $precision if $return_meta;
Branch: 1 branch
BranchTrueFalseTotal
if $return_meta 0 0 0
4064  
4065 0 ▶ if ($parsed->{env_hashes}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"env_hashes"}) 0 0 0
4066 0 require Data::Clone;
4067 $envres->[3]{'func.scenario_env_hashes'} =
4068 0 Data::Clone::clone($parsed->{env_hashes});
4069 }
4070  
4071 0 log_trace("Running benchmark with %s (precision=%g) ...", $runner, $precision);
4072  
4073 0 my @columns = ('seq' , 'participant', 'dataset');
4074 0 my @column_aligns = ('right', 'left' , 'left');
4075 0 my @column_formats = (undef , undef , undef);
4076 0 my @rows;
4077 my %arg_size_columns;
4078 0 ▶ if ($args{multiperl} || $args{multimodver}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args{'multiperl'} or $args{'multimodver'}) { } 0 0 0
Condition0%0/3
$args{"multiperl"} or $args{"multimodver"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"multiperl"} or $args{"multimodver"}
$args{"multiperl"} $args{"multimodver"}
Truth table0%0/3
A or B
A= $args{"multiperl"}B= $args{"multimodver"}
ABresult
1X1
011
000
4079 0 require Data::Clone;
4080 0 require Devel::Size;
4081 0 my %perl_exes;
4082 my %perl_opts;
4083 0 for my $it (@$items) {
4084 0 $perl_exes{$it->{perl}} = $it->{_perl_exe};
4085 0 ▶ $perl_opts{$it->{modver}} = $it->{_perl_opts} if defined $it->{modver};
Branch: 1 branch
BranchTrueFalseTotal
if defined $it->{"modver"} 0 0 0
4086 }
4087 0 ▶ if (!keys(%perl_opts)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (keys %perl_opts) 0 0 0
4088 0 $perl_opts{""} = [];
4089 }
4090  
4091 0 my $sc = Data::Clone::clone($parsed);
4092 0 ▶ for (keys %$sc) { delete $sc->{$_} if /^(before|after)_/ } # remove all hooks
Branch: 1 branch
BranchTrueFalseTotal
if /^(before|after)_/ 0 0 0
4093  
4094 0 my %item_mems; # key = item seq
4095 0 for my $perl (sort keys %perl_exes) {
4096 0 for my $modver (sort keys %perl_opts) {
4097 0 my $scd_path = _get_tempfile_path(\%args, "scenario-$perl");
4098 0 $sc->{items} = [];
4099 0 for my $it (@$items) {
4100 0 ▶ next unless $it->{perl} eq $perl;
Branch: 1 branch
BranchTrueFalseTotal
unless $it->{"perl"} eq $perl 0 0 0
4101 next unless !length($it->{modver}) ||
4102 0 ▶ $it->{modver} eq $modver;
Branch: 1 branch
BranchTrueFalseTotal
unless not length $it->{"modver"} or $it->{"modver"} eq $modver 0 0 0
Condition0%0/3
not length $it->{"modver"} or $it->{"modver"} eq $modver
l!l&&r!l&&!r
000
MC/DC0%0/2
not length $it->{"modver"} or $it->{"modver"} eq $modver
not length $it->{"modver"} $it->{"modver"} eq $modver
Truth table0%0/3
not(A) or B
A= not length $it->{"modver"}B= $it->{"modver"} eq $modver
ABresult
1X1
011
000
4103 0 ▶ next if $item_mems{$it->{seq}}++; # avoid duplicate item
Branch: 1 branch
BranchTrueFalseTotal
if $item_mems{$it->{"seq"}}++ 0 0 0
4104 0 ▶ if (defined $it->{_code_str}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $it->{'_code_str'}) { } 0 0 0
4105 0 delete $it->{_code}; # we'll be using _code_str
4106 } else {
4107 0 die "BUG: Can't dump scenario: no _code_str"; # shouldn't happen
4108 }
4109 0 push @{$sc->{items}}, $it;
4110 }
4111 #use DD; dd {perl=>$perl, modver=>$modver, items=>$sc->{items}};
4112 0 log_debug("Creating scenario dump file for %s (modver %s) at %s", $perl, $modver, $scd_path);
4113 0 ▶ open my($fh), ">", $scd_path or die "Can't open file $scd_path: $!";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $scd_path or die "Can't open file ${scd_path}: $!" 0 0 0
4114 0 print $fh dmp($sc), ";\n";
4115 0 close $fh;
4116 0 _maybe_tidy_script(\%args, $scd_path);
4117 0 my $res_path = _get_tempfile_path(\%args, "benchresult-$perl");
4118 my $cmd = join(
4119 " ",
4120 $perl_exes{$perl},
4121 "-MBencher::Backend",
4122 "-MData::Dmp",
4123 0 ▶ @{ $perl_opts{$modver} // [] },
Condition0%0/2
$perl_opts{$modver} // []
l!l
00
MC/DC0%0/1
$perl_opts{$modver} // []
$perl_opts{$modver}
Truth table0%0/2
A
A= $perl_opts{$modver}
Aresult
11
00
4124 "-e'print dmp(Bencher::Backend::bencher(action=>q[bench], runner=>q[$runner], precision=>$precision, scenario_file=>q[$scd_path], with_args_size=>q[$with_args_size], with_result_size=>q[$with_result_size], return_meta=>0, capture_stdout=>$capture_stdout, capture_stderr=>$capture_stderr))' > '$res_path'",
4125 );
4126 0 log_debug("Running %s ...", $cmd);
4127 0 system $cmd;
4128 0 ▶ die "Failed running bencher for perl $perl (1)" if $?;
Branch: 1 branch
BranchTrueFalseTotal
if $? 0 0 0
4129 0 my $res = do $res_path;
4130 0 ▶ die "Failed running bencher for perl $perl (2): can't parse result: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
4131 0 ▶ die "Failed running bencher for perl $perl (3): result not an enveloped result" if ref($res) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $res ne "ARRAY" 0 0 0
4132 0 ▶ die "Failed running bencher for perl $perl (4): $res->[0] - $res->[1]" if $res->[0] != 200;
Branch: 1 branch
BranchTrueFalseTotal
if $res->[0] != 200 0 0 0
4133  
4134 0 for my $row (@{ $res->[2] }) {
4135 0 $row->{perl} = $perl;
4136 0 ▶ unless (grep {$_ eq 'perl'} @columns) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq "perl";} @columns) 0 0 0
4137 0 push @columns, "perl";
4138 0 push @column_aligns, 'left';
4139 0 push @column_formats, undef;
4140 }
4141 0 ▶ if (length $modver) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $modver) 0 0 0
4142 0 $row->{modver} = $modver;
4143 0 ▶ unless (grep {$_ eq 'modver'} @columns) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$_ eq "modver";} @columns) 0 0 0
4144 0 push @columns, "modver";
4145 0 push @column_aligns, "left";
4146 0 push @column_formats, undef;
4147 }
4148  
4149 }
4150 0 push @rows, $row;
4151 }
4152 } # for modver
4153 } # for perl
4154 } else {
4155 0 my $tres;
4156 0 ▶ my $doit = sub {
Subroutine __ANON__: not called CC=1 SCAR=1.2
4157 3 ▶ no strict 'refs'; ## no critic: TestingAndDebugging::ProhibitNoStrict
Subroutine BEGIN: called CC=1 SCAR=0.0
4158 0 $tres = &{"$runner\::_timethese_guts"}(
4159 $precision,
4160 {
4161 0 map { $_->{seq} => $_->{_code} } @$items
4162 },
4163 "silent",
4164 );
4165 0 };
4166  
4167 0 ▶ if ($capture_stdout && $capture_stderr) {
Branch: 3 branches
BranchTrueFalseTotal
if ($capture_stdout and $capture_stderr) { } 0 0 0
elsif ($capture_stdout) { } 0 0 0
elsif ($capture_stderr) { } 0 0 0
Condition0%0/3
$capture_stdout and $capture_stderr
!ll&&!rl&&r
000
MC/DC0%0/2
$capture_stdout and $capture_stderr
$capture_stdout $capture_stderr
Truth table0%0/3
A and B
A= $capture_stdoutB= $capture_stderr
ABresult
0X0
100
111
4168 0 my ($stdout, $stderr, @res) = &Capture::Tiny::capture($doit);
4169 } elsif ($capture_stdout) {
4170 0 my ($stdout, @res) = &Capture::Tiny::capture_stdout($doit);
4171 } elsif ($capture_stderr) {
4172 0 my ($stdout, @res) = &Capture::Tiny::capture_stderr($doit);
4173 } else {
4174 0 $doit->();
4175 }
4176  
4177 0 ▶ if ($return_meta) {
Branch: 1 branch
BranchTrueFalseTotal
if ($return_meta) 0 0 0
4178 0 $envres->[3]{'func.time_end'} = Time::HiRes::time();
4179 $envres->[3]{'func.elapsed_time'} =
4180 0 $envres->[3]{'func.time_end'} - $envres->[3]{'func.time_start'};
4181 $envres->[3]{'func.sysload_after'} = [Sys::Load::getload()]
4182 0 ▶ if $INC{"System/Load.pm"};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"System/Load.pm"} 0 0 0
4183 }
4184  
4185 0 for my $seq (sort {$a<=>$b} keys %$tres) {
4186 0 my $it = _find_record_by_seq($items, $seq);
4187 my $row = {
4188 rate => 1 / $tres->{$seq}{result}{num},
4189 time => $tres->{$seq}{result}{num},
4190  
4191 ($with_args_size && $it->{_arg_sizes} ?
4192 0 (map { my $c = "arg_${_}_size"; $arg_size_columns{$c}++; ($c => $it->{_arg_sizes}{$_})}
4193 0 keys %{ $it->{_arg_sizes} }) : ()),
4194  
4195 (result_size => $it->{_result_size}) x !!$with_result_size,
4196  
4197 errors => $tres->{$seq}{result}{errors}[0],
4198 samples => $tres->{$seq}{result}{_dbr_nsamples},
4199 notes => $it->{_code_error},
4200 0 ▶ };
Branch: 1 branch
BranchTrueFalseTotal
$with_args_size && $it->{'_arg_sizes'} ? : 0 0 0
Condition0%0/3
$with_args_size and $it->{"_arg_sizes"}
!ll&&!rl&&r
000
MC/DC0%0/2
$with_args_size and $it->{"_arg_sizes"}
$with_args_size $it->{"_arg_sizes"}
Truth table0%0/3
A and B
A= $with_args_sizeB= $it->{"_arg_sizes"}
ABresult
0X0
100
111
4201  
4202 0 for my $k (sort keys %$it) {
4203 0 ▶ next unless $k =~ /^(seq|participant|p_.+|dataset|ds_.+|env_hash|perl|modver|item_.+|arg_.+|proc_.+)$/;
Branch: 1 branch
BranchTrueFalseTotal
unless $k =~ /^(seq|participant|p_.+|dataset|ds_.+|env_hash|perl|modver|item_.+|arg_.+|proc_.+)$/ 0 0 0
4204 0 ▶ unless (grep {$k eq $_} @columns) {
Branch: 1 branch
BranchTrueFalseTotal
unless (grep {$k eq $_;} @columns) 0 0 0
4205 0 push @columns, $k;
4206 0 push @column_aligns, 'left';
4207 0 push @column_formats, undef;
4208 }
4209 0 $row->{$k} = $it->{$k};
4210 }
4211 0 push @rows, $row;
4212 }
4213 }
4214  
4215 0 push @columns, 'seq' , 'rate' , 'time';
4216 0 push @column_aligns, 'number', 'number', 'number';
4217 0 push @column_formats, undef , undef , undef;
4218  
4219 0 ▶ if ($with_args_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_args_size) 0 0 0
4220 0 for my $col (keys %arg_size_columns) {
4221 0 push @columns, $col;
4222 0 push @column_aligns, 'number';
4223 0 push @column_formats, undef;
4224 }
4225 }
4226 0 ▶ if ($with_result_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($with_result_size) 0 0 0
4227 0 push @columns, qw/result_size/;
4228 0 push @column_aligns, 'number';
4229 0 push @column_formats, undef;
4230 }
4231 # XXX proc_* fields should be put here
4232 0 push @columns , 'errors', 'samples', 'notes';
4233 0 push @column_aligns, 'number', 'number' , 'left';
4234 0 push @column_formats, undef , undef , undef;
4235  
4236 0 $envres->[2] = \@rows;
4237 0 $envres->[3]{'table.fields'} = \@columns;
4238 0 $envres->[3]{'table.field_aligns'} = \@column_aligns;
4239 0 $envres->[3]{'table.field_formats'} = \@column_formats;
4240  
4241 0 ▶ if (grep { $_->{time} && $_->{time} < 0 } @{ $envres->[2] }) {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_->{"time"} and $_->{"time"} < 0;} @{$$envres[2];}) 0 0 0
Condition0%0/3
$_->{'time'} && $_->{'time'} < 0
!ll&&!rl&&r
000
MC/DC0%0/2
$_->{'time'} && $_->{'time'} < 0
$_->{'time'} $_->{'time'} < 0
Truth table0%0/3
A && B
A= $_->{'time'}B= $_->{'time'} < 0
ABresult
0X0
100
111
4242 0 warn "There are some negative time in the results, you might ".
4243 "want to increase the precision";
4244 }
4245  
4246 0 ▶ if ($parsed->{after_bench}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"after_bench"}) 0 0 0
4247 0 log_info("Executing after_bench hook ...");
4248 0 $parsed->{after_bench}->(
4249 hook_name => 'after_bench',
4250 scenario => $parsed,
4251 stash => $stash,
4252 result => $envres,
4253 );
4254 }
4255  
4256 0 ▶ if ($return_meta) {
Branch: 1 branch
BranchTrueFalseTotal
if ($return_meta) 0 0 0
4257 0 $envres->[3]{'func.platform_info'} =
4258 Devel::Platform::Info->new->get_info;
4259 0 my $info = Sys::Info->new;
4260 0 $envres->[3]{'func.cpu_info'} = [$info->device('CPU')->identify];
4261 0 ▶ $envres->[3]{'func.note'} = $args{note} if exists $args{note};
Branch: 1 branch
BranchTrueFalseTotal
if exists $args{"note"} 0 0 0
4262 }
4263  
4264 # XXX separate to sub?
4265 0 ▶ if ($save_result) {
Branch: 1 branch
BranchTrueFalseTotal
if ($save_result) 0 0 0
4266 0 require Data::Clean::ForJSON;
4267 0 require File::Slurper;
4268 0 require JSON::MaybeXS;
4269 0 require POSIX;
4270  
4271 0 ▶ my $result_filename = $args{result_filename} // do {
Condition0%0/3
$args{"result_filename"} // do { my $mod = $args{"scenario_module"} // "NO_MODULE"; $mod =~ s[(::|/)][-]g; sprintf "%s%s.%s.json", $mod, $module_startup ? ".module_startup" : ($code_startup ? ".code_startup" : ""), POSIX::strftime("%Y-%m-%dT%H-%M-%S", localtime $time_start) }
l!l&&r!l&&!r
000
MC/DC0%0/2
$args{"result_filename"} // do { my $mod = $args{"scenario_module"} // "NO_MODULE"; $mod =~ s[(::|/)][-]g; sprintf "%s%s.%s.json", $mod, $module_startup ? ".module_startup" : ($code_startup ? ".code_startup" : ""), POSIX::strftime("%Y-%m-%dT%H-%M-%S", localtime $time_start) }
$args{"result_filename"} do { my $mod = $args{"scenario_module"} // "NO_MODULE"; $mod =~ s[(::|/)][-]g; sprintf "%s%s.%s.json", $mod, $module_startup ? ".module_startup" : ($code_startup ? ".code_startup" : ""), POSIX::strftime("%Y-%m-%dT%H-%M-%S", localtime $time_start) }
Truth table0%0/3
A // B
A= $args{"result_filename"}B= do { my $mod = $args{"scenario_module"} // "NO_MODULE"; $mod =~ s[(::|/)][-]g; sprintf "%s%s.%s.json", $mod, $module_startup ? ".module_startup" : ($code_startup ? ".code_startup" : ""), POSIX::strftime("%Y-%m-%dT%H-%M-%S", localtime $time_start) }
ABresult
1X1
011
000
4272 0 ▶ my $mod = $args{scenario_module} // "NO_MODULE";
Condition0%0/2
$args{"scenario_module"} // "NO_MODULE"
l!l
00
MC/DC0%0/1
$args{"scenario_module"} // "NO_MODULE"
$args{"scenario_module"}
Truth table0%0/2
A
A= $args{"scenario_module"}
Aresult
11
00
4273 0 $mod =~ s!(::|/)!-!g;
4274 0 ▶ sprintf(
Branch: 2 branches
BranchTrueFalseTotal
$module_startup ? : 0 0 0
$code_startup ? : 0 0 0
4275 "%s%s.%s.json",
4276 $mod,
4277 $module_startup ? ".module_startup" :
4278 $code_startup ? ".code_startup" : "",
4279 POSIX::strftime("%Y-%m-%dT%H-%M-%S",
4280 localtime($time_start)),
4281 );
4282 };
4283 0 my $path = "$result_dir/$result_filename";
4284 0 my $cleanser = Data::Clean::ForJSON->get_cleanser;
4285 0 log_trace("Saving result to %s ...", $path);
4286 0 File::Slurper::write_text(
4287 $path,
4288 JSON::MaybeXS::encode_json(
4289 $cleanser->clone_and_clean($envres)
4290 )
4291 );
4292 }
4293  
4294 FORMAT:
4295 {
4296 0 ▶ last unless $is_cli_and_can_format_as_table;
Branch: 1 branch
BranchTrueFalseTotal
unless $is_cli_and_can_format_as_table 0 0 0
4297  
4298 my $fres = format_result($envres, undef, {
4299 sort => $args{sorts},
4300 scientific_notation => $args{scientific_notation},
4301 render_as_benchmark_pm => $args{render_as_benchmark_pm},
4302 render_as_text_table => $is_cli_and_text_format && !$args{render_as_benchmark_pm},
4303 0 ▶ });
Condition0%0/3
$is_cli_and_text_format && !$args{'render_as_benchmark_pm'}
!ll&&!rl&&r
000
MC/DC0%0/2
$is_cli_and_text_format && !$args{'render_as_benchmark_pm'}
$is_cli_and_text_format !$args{'render_as_benchmark_pm'}
Truth table0%0/3
A && not(B)
A= $is_cli_and_text_formatB= !$args{'render_as_benchmark_pm'}
ABresult
0X0
100
111
4304  
4305 0 ▶ if ($is_cli_and_text_format) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_cli_and_text_format) 0 0 0
4306 0 my $num_cores = $envres->[3]{'func.cpu_info'}[0]{number_of_cores};
4307 my $platform_info = join(
4308 "",
4309 "Run on: ",
4310 "perl ", _ver_or_vers($envres->[3]{'func.module_versions'}{perl}), ", ",
4311 "CPU ", $envres->[3]{'func.cpu_info'}[0]{name}, " ($num_cores cores), ",
4312 "OS ", $envres->[3]{'func.platform_info'}{osname}, " ", $envres->[3]{'func.platform_info'}{oslabel}, " version ", $envres->[3]{'func.platform_info'}{osvers}, ", ",
4313 "OS kernel: ", $envres->[3]{'func.platform_info'}{kname}, " version ", $envres->[3]{'func.platform_info'}{kvers},
4314 0 );
4315 my $elapsed_info = join(
4316 "",
4317 "Elapsed time: ",
4318 0 sprintf("%.2fs", $envres->[3]{'func.elapsed_time'}),
4319 );
4320 0 $fres = "# $platform_info\n# $elapsed_info\n$fres";
4321 }
4322  
4323 0 ▶ $envres = $is_cli_and_text_format ?
Branch: 1 branch
BranchTrueFalseTotal
$is_cli_and_text_format ? : 0 0 0
4324 [200, "OK", $fres, {"cmdline.skip_format" => 1}] : $fres;
4325 }
4326  
4327 RETURN_RESULT:
4328  
4329 0 goto L_END;
4330  
4331 }
4332  
4333 0 $envres = [400,"Unknown action"];
4334  
4335 L_END:
4336  
4337 0 ▶ if ($parsed->{before_return}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parsed->{"before_return"}) 0 0 0
4338 0 log_info("Executing before_return hook ...");
4339 0 $parsed->{before_return}->(
4340 hook_name => 'before_return',
4341 scenario => $parsed,
4342 stash => $stash,
4343 result => $envres,
4344 );
4345 }
4346  
4347 0 $envres;
4348 }
4349  
4350 $SPEC{parse_scenario} = {
4351 3 v => 1.1,
4352 summary => 'Parse scenario (fill in default values, etc)',
4353 args => {
4354 scenario => {
4355 summary => 'Unparsed scenario',
4356 schema => 'hash*',
4357 },
4358 },
4359 };
4360 0 ▶sub parse_scenario {
Subroutine parse_scenario: not called CC=1 SCAR=6.9
Pod documented
4361 0 my %args = @_;
4362  
4363 0 _parse_scenario(scenario => $args{scenario}, parent_args => {});
4364 }
4365  
4366 3 1;
4367 # ABSTRACT: Backend for Bencher
4368  
4369 __END__
↑ Summary Bencher/Role/FieldMunger.pm »