blib/lib/Devel/StatProfiler/Report.pm

filter: Statementstmt 45.3% 267 / 589 Branchbran 33.4% 85 / 254 Conditioncond 29.6% 59 / 199 MC/DCmcdc 14.2% 17 / 119 Subroutinesub 58.4% 38 / 65 Podpod 0.0% 0 / 16 totaltotal 37.5% 466 / 1242 CC 241 SCAR 50.7
CC
241
Cov
39%
output
812.0
__ANON__
462.0
_merged_entry
342.0
CRAP 158.5
« blib/lib/auto/share/dist/Devel-StatProfiler/flamegraph.pl ↑ Summary blib/lib/Devel/StatProfiler.pm »
1 package Devel::StatProfiler::Report;
2 # ABSTRACT: process profiler output to generate a report
3  
4 24 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 24 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 24 ▶use autodie qw(open close chdir);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 24 ▶use Devel::StatProfiler::Reader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 24 ▶use Devel::StatProfiler::EvalSource;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 24 ▶use Devel::StatProfiler::SourceMap;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 24 ▶use Devel::StatProfiler::Metadata;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 24 ▶use Devel::StatProfiler::Utils qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
13 check_serializer
14 read_data
15 state_dir
16 utf8_sha1_hex
17 write_data_any
18 24 );
19 24 ▶use Devel::StatProfiler::Slowops;
Subroutine BEGIN: called CC=1 SCAR=0.0
20 24 ▶use Devel::StatProfiler::FlameGraph;
Subroutine BEGIN: called CC=1 SCAR=0.0
21 24 ▶use File::ShareDir;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 24 ▶use File::Basename ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 24 ▶use File::Spec::Functions ();
Subroutine BEGIN: called CC=1 SCAR=0.0
24 24 ▶use File::Copy ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25 24 ▶use File::Path ();
Subroutine BEGIN: called CC=1 SCAR=0.0
26 24 ▶use Text::MicroTemplate;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 24 ▶use IO::Compress::Gzip;
Subroutine BEGIN: called CC=1 SCAR=0.0
28 24 ▶use POSIX ();
Subroutine BEGIN: called CC=1 SCAR=0.0
29  
30 24 my $NO_SOURCE = ['Source not available...'];
31  
32 24 my %TEMPLATES = (
33 file => _get_template('file.tmpl'),
34 subs => _get_template('subs.tmpl'),
35 files => _get_template('files.tmpl'),
36 index => _get_template('index.tmpl'),
37 header => _get_template('header.tmpl'),
38 );
39  
40 24 my %SPECIAL_SUBS = map { $_ => 1 } qw(
41 BEGIN
42 UNITCHECK
43 CHECK
44 INIT
45 END
46 );
47  
48 12136 ▶sub new {
Subroutine new: called CC=11 SCAR=24.0
Pod undocumented
49 12136 my ($class, %opts) = @_;
50 12136 ▶ my $mapper = $opts{mapper} && $opts{mapper}->can_map ? $opts{mapper} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$opts{'mapper'} && $opts{'mapper'}->can_map ? : 2 12134 12136
Condition66%2/3
$opts{"mapper"} and $opts{"mapper"}->can_map
!ll&&!rl&&r
1213402
MC/DC50%1/2
$opts{"mapper"} and $opts{"mapper"}->can_map
$opts{"mapper"} $opts{"mapper"}->can_map
Truth table66%2/3
A and B
A= $opts{"mapper"}B= $opts{"mapper"}->can_map
ABresult
0X0
100
111
51 my $self = bless {
52 aggregate => {
53 total => 0,
54 subs => {},
55 flames => {},
56 files => {},
57 },
58 $opts{sources} ? (
59 source => Devel::StatProfiler::EvalSource->new(
60 serializer => $opts{serializer},
61 genealogy => {},
62 root_dir => $opts{root_directory},
63 shard => $opts{shard},
64 ),
65 sourcemap => Devel::StatProfiler::SourceMap->new(
66 serializer => $opts{serializer},
67 root_dir => $opts{root_directory},
68 shard => $opts{shard},
69 ),
70 ) : (
71 source => undef,
72 sourcemap => undef,
73 ),
74 metadata => Devel::StatProfiler::Metadata->new(
75 serializer => $opts{serializer},
76 root_directory => $opts{root_directory},
77 shard => $opts{shard},
78 ),
79 genealogy => {},
80 flamegraph => $opts{flamegraph} || 0,
81 208378 ▶ slowops => {map { $_ => 1 } @{$opts{slowops} || \@Devel::StatProfiler::Slowops::OPS}},
Branch: 1 branch
BranchTrueFalseTotal
$opts{'mixed_process'} ? : 2995 9141 12136
Condition88%8/9
$opts{'slowops'} || \@Devel::StatProfiler::Slowops::OPS
l!l
108751261
$opts{'serializer'} || 'storable'
l!l
101202016
$opts{'fetchers'} || [[undef, 'fetch_source_from_file']]
l!l
012136
$opts{"parts_directory"} // $opts{"root_directory"}
l!l&&r!l&&!r
1011462016
MC/DC100%1/1
$opts{'slowops'} || \@Devel::StatProfiler::Slowops::OPS
$opts{'slowops'}
MC/DC100%1/1
$opts{'serializer'} || 'storable'
$opts{'serializer'}
MC/DC0%0/1
$opts{'fetchers'} || [[undef, 'fetch_source_from_file']]
$opts{'fetchers'}
MC/DC100%2/2
$opts{"parts_directory"} // $opts{"root_directory"}
$opts{"parts_directory"} $opts{"root_directory"}
Truth table100%2/2
A
A= $opts{'slowops'}
Aresult
11
00
Truth table100%2/2
A
A= $opts{'serializer'}
Aresult
11
00
Truth table50%1/2
A
A= $opts{'fetchers'}
Aresult
11
00
Truth table100%3/3
A // B
A= $opts{"parts_directory"}B= $opts{"root_directory"}
ABresult
1X1
011
000
82 tick => 0,
83 stack_depth => 0,
84 perl_version => undef,
85 mapper => $mapper,
86 process_id => $opts{mixed_process} ? 'mixed' : undef,
87 serializer => $opts{serializer} || 'storable',
88 fetchers => $opts{fetchers} || [[undef, 'fetch_source_from_file']],
89 shard => $opts{shard},
90 root_dir => $opts{root_directory},
91 parts_dir => $opts{parts_directory} // $opts{root_directory},
92 shard => $opts{shard},
93 suffix => $opts{suffix},
94 12136 ▶ }, $class;
Branch: 1 branch
BranchTrueFalseTotal
$opts{'sources'} ? : 9 12127 12136
Condition100%2/2
$opts{'flamegraph'} || 0
l!l
200510131
MC/DC100%1/1
$opts{'flamegraph'} || 0
$opts{'flamegraph'}
Truth table100%2/2
A
A= $opts{'flamegraph'}
Aresult
11
00
95  
96 12136 ▶ if ($self->{flamegraph}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flamegraph"}) 2005 10131 12136
97 2005 my $fg = File::ShareDir::dist_file('Devel-StatProfiler', 'flamegraph.pl');
98 2005 $self->{fg_cmd} = "$^X $fg --nametype=sub --countname=samples";
99 }
100  
101 12136 check_serializer($self->{serializer});
102  
103 12136 return $self;
104 }
105  
106 120 ▶sub _get_template {
Subroutine _get_template: called CC=2 SCAR=7.0
107 120 my ($basename) = @_;
108 120 my $path = File::ShareDir::dist_file('Devel-StatProfiler', $basename);
109 120 my $tmpl = do {
110 120 local $/;
111 120 ▶ open my $fh, '<:utf8', $path or die "Unable to open '$path': $!";
Branch: 1 branch
BranchTrueFalseTotal
&Devel::StatProfiler::Report::open(my $fh, "<:utf8", $path) or die "Unable to open '${path}': $!" 120 0 120
112 120 readline $fh;
113 };
114  
115 120 return Text::MicroTemplate::build_mt($tmpl);
116 }
117  
118 0 ▶sub _write_template {
Subroutine _write_template: not called CC=5 SCAR=34.0
119 0 my ($self, $sub, $data, $dir, $file, $compress) = @_;
120 0 my $text = $sub->($data) . "";
121 0 my $target = File::Spec::Functions::catfile($dir, $file);
122  
123 0 ▶ utf8::encode($text) if utf8::is_utf8($text);
Branch: 1 branch
BranchTrueFalseTotal
if utf8::is_utf8($text) 0 0 0
124 0 ▶ open my $fh, '>', $compress ? "$target.gz" : $target;
Branch: 1 branch
BranchTrueFalseTotal
$compress ? : 0 0 0
125 0 ▶ if ($compress) {
Branch: 1 branch
BranchTrueFalseTotal
if ($compress) { } 0 0 0
126 0 ▶ IO::Compress::Gzip::gzip(\$text, $fh)
Branch: 1 branch
BranchTrueFalseTotal
IO::Compress::Gzip::gzip(\$text, $fh) or die "gzip failed: $IO::Compress::Gzip::GzipError" 0 0 0
127 or die "gzip failed: $IO::Compress::Gzip::GzipError";
128 } else {
129 0 print $fh $text;
130 }
131 0 close $fh;
132 }
133  
134 0 ▶sub _compress_inplace {
Subroutine _compress_inplace: not called CC=2 SCAR=17.9
135 0 my ($self, $path) = @_;
136  
137 0 ▶ IO::Compress::Gzip::gzip($path, "$path.gz")
Branch: 1 branch
BranchTrueFalseTotal
IO::Compress::Gzip::gzip($path, "$path.gz") or die "gzip failed: $IO::Compress::Gzip::GzipError" 0 0 0
138 or die "gzip failed: $IO::Compress::Gzip::GzipError";
139 0 unlink $path;
140 }
141  
142 138654 ▶sub _sub {
Subroutine _sub: called CC=6 SCAR=18.6
143 138654 my ($self, $frame, $file) = @_;
144 138654 my $uq_name = $frame->uq_sub_name;
145 138654 ▶ my $name = $frame->fq_sub_name || $uq_name;
Condition66%2/3
$frame->fq_sub_name || $uq_name
l!l&&r!l&&!r
121217174370
MC/DC0%0/2
$frame->fq_sub_name || $uq_name
$frame->fq_sub_name $uq_name
Truth table66%2/3
A || B
A= $frame->fq_sub_nameB= $uq_name
ABresult
1X1
011
000
146  
147 138654 ▶ return $self->{aggregate}{subs}{$uq_name} ||= {
Condition72%8/11
$self->{"aggregate"}{"subs"}{$uq_name} ||= {"name", $name, "name_pretty", $frame->sub_name_pretty || $name, "uq_name", $uq_name, "package", $frame->package, "file", $file // $frame->file, "file_pretty", $file // $frame->file_pretty, "inclusive", 0, "exclusive", 0, "callees", {}, "call_sites", {}, "start_line", $frame->first_line, "kind", $frame->kind, "is_main", $frame->is_main, "is_eval", $frame->is_eval}
l!l
12116817486
$frame->sub_name_pretty || $name
l!l&&r!l&&!r
37174490
$file // $frame->file
l!l&&r!l&&!r
118173680
$file // $frame->file_pretty
l!l&&r!l&&!r
118173680
MC/DC100%1/1
$self->{"aggregate"}{"subs"}{$uq_name} ||= {"name", $name, "name_pretty", $frame->sub_name_pretty || $name, "uq_name", $uq_name, "package", $frame->package, "file", $file // $frame->file, "file_pretty", $file // $frame->file_pretty, "inclusive", 0, "exclusive", 0, "callees", {}, "call_sites", {}, "start_line", $frame->first_line, "kind", $frame->kind, "is_main", $frame->is_main, "is_eval", $frame->is_eval}
$self->{"aggregate"}{"subs"}{$uq_name}
MC/DC0%0/2
$frame->sub_name_pretty || $name
$frame->sub_name_pretty $name
MC/DC0%0/2
$file // $frame->file
$file $frame->file
MC/DC0%0/2
$file // $frame->file_pretty
$file $frame->file_pretty
Truth table100%2/2
A
A= $self->{"aggregate"}{"subs"}{$uq_name}
Aresult
11
00
Truth table66%2/3
A || B
A= $frame->sub_name_prettyB= $name
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $fileB= $frame->file
ABresult
1X1
011
000
Truth table66%2/3
A // B
A= $fileB= $frame->file_pretty
ABresult
1X1
011
000
148 name => $name,
149 name_pretty=> $frame->sub_name_pretty || $name,
150 uq_name => $uq_name,
151 package => $frame->package,
152 file => $file // $frame->file,
153 file_pretty=> $file // $frame->file_pretty,
154 inclusive => 0,
155 exclusive => 0,
156 callees => {},
157 call_sites => {},
158 start_line => $frame->first_line,
159 kind => $frame->kind,
160 is_main => $frame->is_main,
161 is_eval => $frame->is_eval,
162 };
163 }
164  
165 391 ▶sub _xssub {
Subroutine _xssub: called CC=1 SCAR=0.0
166 391 my ($self, $frame) = @_;
167 391 my $xs_file = 'xs:' . ($frame->package =~ s{::}{/}rg) . '.pm';
168  
169 391 return $self->_sub($frame, $xs_file);
170 }
171  
172 138654 ▶sub _file {
Subroutine _file: called CC=2 SCAR=6.9
173 138654 my ($self, $file, $file_pretty) = @_;
174  
175 138654 ▶ return $self->{aggregate}{files}{$file} ||= {
Condition100%2/2
$self->{"aggregate"}{"files"}{$file} ||= {"name", $file_pretty, "lines", {"exclusive", [], "inclusive", []}, "report", sprintf("%s-line.html", _fileify($file)), "exclusive", 0, "subs", {}}
l!l
1303128342
MC/DC100%1/1
$self->{"aggregate"}{"files"}{$file} ||= {"name", $file_pretty, "lines", {"exclusive", [], "inclusive", []}, "report", sprintf("%s-line.html", _fileify($file)), "exclusive", 0, "subs", {}}
$self->{"aggregate"}{"files"}{$file}
Truth table100%2/2
A
A= $self->{"aggregate"}{"files"}{$file}
Aresult
11
00
176 name => $file_pretty,
177 lines => {
178 exclusive => [],
179 inclusive => [],
180 },
181 report => sprintf('%s-line.html', _fileify($file)),
182 exclusive => 0,
183 subs => {},
184 };
185 }
186  
187 18779 ▶sub _check_consistency {
Subroutine _check_consistency: called CC=11 SCAR=31.1
188 18779 my ($self, $tick, $perl_version, $process_id, $file) = @_;
189  
190 18779 ▶ if ($self->{tick} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'tick'} == 0) { } 8792 9987 18779
191 8792 $self->{tick} = $tick;
192 8792 $self->{perl_version} = $perl_version;
193 8792 ▶ $self->{process_id} //= $process_id;
Condition66%2/3
$self->{"process_id"} //= $process_id
l!l&&r!l&&!r
298658060
MC/DC0%0/2
$self->{"process_id"} //= $process_id
$self->{"process_id"} $process_id
Truth table66%2/3
A //= B
A= $self->{"process_id"}B= $process_id
ABresult
1X1
011
000
194 } else {
195 9987 ▶ if ($tick != $self->{tick} ||
Branch: 1 branch
BranchTrueFalseTotal
if ($tick != $self->{"tick"} or $perl_version ne $self->{"perl_version"}) 0 9987 9987
Condition33%1/3
$tick != $self->{"tick"} or $perl_version ne $self->{"perl_version"}
l!l&&r!l&&!r
009987
MC/DC0%0/2
$tick != $self->{"tick"} or $perl_version ne $self->{"perl_version"}
$tick != $self->{"tick"} $perl_version ne $self->{"perl_version"}
Truth table33%1/3
A or B
A= $tick != $self->{"tick"}B= $perl_version ne $self->{"perl_version"}
ABresult
1X1
011
000
196 $perl_version ne $self->{perl_version}) {
197 0 die <<EOT;
198 Inconsistent sampling parameters:
199 Current tick duration: $self->{tick} Perl version: $self->{perl_version}
200  
201 $file sampling parameters:
202 Tick duration: $tick Perl version: $perl_version
203 EOT
204 }
205  
206 9987 ▶ if ($self->{process_id} ne 'mixed' &&
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"process_id"} ne "mixed" and ($process_id // "undef") ne ($self->{"process_id"} // "undef")) 0 9987 9987
Condition57%4/7
$self->{"process_id"} ne "mixed" and ($process_id // "undef") ne ($self->{"process_id"} // "undef")
!ll&&!rl&&r
185581320
$process_id // "undef"
l!l
81320
$self->{"process_id"} // "undef"
l!l
81320
MC/DC50%1/2
$self->{"process_id"} ne "mixed" and ($process_id // "undef") ne ($self->{"process_id"} // "undef")
$self->{"process_id"} ne "mixed" $process_id
MC/DC0%0/1
$self->{"process_id"} // "undef"
$self->{"process_id"}
Truth table66%2/3
A and B
A= $self->{"process_id"} ne "mixed"B= $process_id
ABresult
0X0
100
111
Truth table50%1/2
A
A= $self->{"process_id"}
Aresult
11
00
207 ($process_id // 'undef') ne ($self->{process_id} // 'undef')) {
208 0 ▶ my ($p1_str, $p2_str) = ($process_id // 'undef', $self->{process_id} // 'undef');
Condition0%0/4
$process_id // "undef"
l!l
00
$self->{"process_id"} // "undef"
l!l
00
MC/DC0%0/1
$process_id // "undef"
$process_id
MC/DC0%0/1
$self->{"process_id"} // "undef"
$self->{"process_id"}
Truth table0%0/2
A
A= $process_id
Aresult
11
00
Truth table0%0/2
A
A= $self->{"process_id"}
Aresult
11
00
209 0 die <<EOT;
210 Inconsistent process IDs:
211 Current process ID: $p2_str
212 $file process ID: $p1_str
213 EOT
214 }
215 }
216 }
217  
218 9998 ▶sub add_trace_file {
Subroutine add_trace_file: called CC=31 SCAR=34.4
Pod undocumented
219 9998 my ($self, $file) = @_;
220 9998 ▶ my $r = ref $file ? $file : Devel::StatProfiler::Reader->new($file, $self->{mapper});
Branch: 1 branch
BranchTrueFalseTotal
ref $file ? : 9980 18 9998
221 9998 ▶ my $flames = $self->{flamegraph} ? $self->{aggregate}{flames} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'flamegraph'} ? : 2008 7990 9998
222 9998 my $slowops = $self->{slowops};
223 9998 ▶ my $eval_mapper = $self->{mapper} && $self->{mapper}->can_map_eval ? $self->{mapper} : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'mapper'} && $self->{'mapper'}->can_map_eval ? : 1 9997 9998
Condition100%3/3
$self->{"mapper"} and $self->{"mapper"}->can_map_eval
!ll&&!rl&&r
999611
MC/DC100%2/2
$self->{"mapper"} and $self->{"mapper"}->can_map_eval
$self->{"mapper"} $self->{"mapper"}->can_map_eval
Truth table100%3/3
A and B
A= $self->{"mapper"}B= $self->{"mapper"}->can_map_eval
ABresult
0X0
100
111
224  
225 my ($process_id, $process_ordinal, $parent_id, $parent_ordinal) =
226 9998 @{$r->get_genealogy_info};
227 $self->{genealogy}{$process_id}{$process_ordinal} = [$parent_id, $parent_ordinal]
228 9998 ▶ if $self->{genealogy};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"genealogy"} 9998 0 9998
229 9998 ▶ $eval_mapper->update_genealogy($process_id, $process_ordinal, $parent_id, $parent_ordinal)
Branch: 1 branch
BranchTrueFalseTotal
if $eval_mapper 1 9997 9998
230 if $eval_mapper;
231 $self->{source}->update_genealogy($process_id, $process_ordinal, $parent_id, $parent_ordinal)
232 9998 ▶ if $self->{source};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"source"} 17 9981 9998
233  
234 9998 $self->_check_consistency(
235 $r->get_source_tick_duration,
236 $r->get_source_perl_version,
237 $process_id,
238 $file,
239 );
240  
241 9998 ▶ while (my $trace = $r->read_trace) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $trace = $r->read_trace) 24631 9998 34629
242 24631 my $weight = $trace->weight;
243  
244 24631 $self->{aggregate}{total} += $weight;
245  
246 24631 my $frames = $trace->frames;
247  
248 # TODO move it to Reader.pm?
249 24631 ▶ if ($slowops->{my $op_name = $trace->op_name}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($$slowops{my $op_name = $trace->op_name}) 12899 11732 24631
250 12899 unshift @$frames, bless {
251 "package" => "CORE",
252 sub_name => $op_name,
253 fq_sub_name=> "CORE::$op_name",
254 file => $frames->[0]->file,
255 line => -2,
256 first_line => -2,
257 }, 'Devel::StatProfiler::StackFrame';
258 }
259  
260 24631 my ($next_sub, @for_flamegraph, %tracked_sub, %tracked_cs, %tracked_callee);
261 24631 for my $i (0 .. $#$frames) {
262 138654 my $frame = $frames->[$i];
263 138654 my $line = $frame->line;
264  
265 # XS vs. normal sub or opcode
266 138654 my $sub = $next_sub;
267 138654 ▶ if ($line == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line == -1) { } 391 138263 138654
268 391 ▶ $sub //= $self->_xssub($frame);
Condition33%1/3
$sub //= $self->_xssub($frame)
l!l&&r!l&&!r
03910
MC/DC0%0/2
$sub //= $self->_xssub($frame)
$sub $self->_xssub($frame)
Truth table33%1/3
A //= B
A= $subB= $self->_xssub($frame)
ABresult
1X1
011
000
269 } else {
270 138263 ▶ $sub //= $self->_sub($frame);
Condition66%2/3
$sub //= $self->_sub($frame)
l!l&&r!l&&!r
114357239060
MC/DC0%0/2
$sub //= $self->_sub($frame)
$sub $self->_sub($frame)
Truth table66%2/3
A //= B
A= $subB= $self->_sub($frame)
ABresult
1X1
011
000
271 }
272 138654 my $file = $self->_file($sub->{file}, $sub->{file_pretty});
273 138654 my $uq_sub_name = $sub->{uq_name};
274 138654 my $recursive = ++$tracked_sub{$uq_sub_name} > 1;
275  
276 138654 ▶ $sub->{inclusive} += $weight unless $recursive;
Branch: 1 branch
BranchTrueFalseTotal
unless $recursive 115672 22982 138654
277 138654 ▶ $file->{lines}{inclusive}[$line] += $weight if $line > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $line > 0 125360 13294 138654
278 138654 $file->{subs}{$sub->{start_line}}{$uq_sub_name} = undef;
279 138654 ▶ push @for_flamegraph, $uq_sub_name if $flames;
Branch: 1 branch
BranchTrueFalseTotal
if $flames 42016 96638 138654
280  
281 138654 ▶ if ($i != $#$frames) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i != $frames->$#*) 114357 24297 138654
282 114357 my $call_site = $frames->[$i + 1];
283 114357 my $call_line = $call_site->line;
284 114357 my $cs_id = sprintf '%s:%d', $call_site->file, $call_site->line;
285 114357 my $caller;
286 114357 ▶ if ($call_line == -1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($call_line == -1) { } 0 114357 114357
287 0 $caller = $next_sub = $self->_xssub($call_site);
288 } else {
289 114357 $caller = $next_sub = $self->_sub($call_site);
290 }
291 my $site = $sub->{call_sites}{$cs_id} ||= {
292 caller => $caller->{uq_name},
293 114357 ▶ exclusive => 0,
Condition100%2/2
$sub->{"call_sites"}{$cs_id} ||= {"caller", $caller->{"uq_name"}, "exclusive", 0, "inclusive", 0, "file", $call_site->file, "line", $call_line}
l!l
9929515062
MC/DC100%1/1
$sub->{"call_sites"}{$cs_id} ||= {"caller", $caller->{"uq_name"}, "exclusive", 0, "inclusive", 0, "file", $call_site->file, "line", $call_line}
$sub->{"call_sites"}{$cs_id}
Truth table100%2/2
A
A= $sub->{"call_sites"}{$cs_id}
Aresult
11
00
294 inclusive => 0,
295 file => $call_site->file,
296 line => $call_line,
297 };
298 114357 my $recursive_cs = ++$tracked_cs{$cs_id} > 1;
299 114357 my $recursive_callee = ++$tracked_callee{"$uq_sub_name:$call_line"} > 1;
300  
301 114357 ▶ $site->{inclusive} += $weight if !$recursive_cs;
Branch: 1 branch
BranchTrueFalseTotal
unless $recursive_cs 97590 16767 114357
302 114357 ▶ $site->{exclusive} += $weight if !$i;
Branch: 1 branch
BranchTrueFalseTotal
unless $i 23253 91104 114357
303  
304 114357 ▶ my $callee = $caller->{callees}{$call_line}{$uq_sub_name} ||= {
Condition100%2/2
$caller->{"callees"}{$call_line}{$uq_sub_name} ||= {"callee", $uq_sub_name, "inclusive", 0}
l!l
9929315064
MC/DC100%1/1
$caller->{"callees"}{$call_line}{$uq_sub_name} ||= {"callee", $uq_sub_name, "inclusive", 0}
$caller->{"callees"}{$call_line}{$uq_sub_name}
Truth table100%2/2
A
A= $caller->{"callees"}{$call_line}{$uq_sub_name}
Aresult
11
00
305 callee => $uq_sub_name,
306 inclusive => 0,
307 };
308  
309 114357 ▶ $callee->{inclusive} += $weight if !$recursive_callee;
Branch: 1 branch
BranchTrueFalseTotal
unless $recursive_callee 98596 15761 114357
310 }
311  
312 138654 ▶ if (!$i) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($i) 24297 114357 138654
313 24297 $sub->{exclusive} += $weight;
314 24297 $file->{exclusive} += $weight;
315 24297 ▶ $file->{lines}{exclusive}[$line] += $weight if $line > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $line > 0 11007 13290 24297
316 }
317 }
318  
319 24631 ▶ $flames->{join ';', reverse @for_flamegraph} += $weight
Branch: 1 branch
BranchTrueFalseTotal
if @for_flamegraph 7071 17560 24631
320 if @for_flamegraph;
321 }
322  
323 9998 ▶ $self->{source}->add_sources_from_reader($r) if $self->{source};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"source"} 17 9981 9998
324 9998 ▶ $self->{sourcemap}->add_sources_from_reader($r) if $self->{sourcemap};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"sourcemap"} 17 9981 9998
325  
326 9998 my $metadata = $r->get_custom_metadata;
327 $self->{metadata}->set_at_inc($metadata->{"\x00at_inc"})
328 9998 ▶ if $self->{source} && $metadata->{"\x00at_inc"};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"source"} and $metadata->{"\0at_inc"} 0 9998 9998
Condition66%2/3
$self->{"source"} and $metadata->{"\0at_inc"}
!ll&&!rl&&r
9981170
MC/DC0%0/2
$self->{"source"} and $metadata->{"\0at_inc"}
$self->{"source"} $metadata->{"\0at_inc"}
Truth table66%2/3
A and B
A= $self->{"source"}B= $metadata->{"\0at_inc"}
ABresult
0X0
100
111
329 }
330  
331 0 ▶sub _map_hash_rx {
Subroutine _map_hash_rx: not called CC=13 SCAR=52.0
332 0 my ($hash, $rx, $subst, $map, $merge) = @_;
333  
334 0 for my $key (keys %$hash) {
335 0 my $value = $hash->{$key};
336 0 my $new_key = $map->{$key};
337  
338 0 ▶ if (!$new_key && $key =~ $rx) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $new_key and $key =~ /$rx/) 0 0 0
Condition0%0/3
not $new_key and $key =~ /$rx/
!ll&&!rl&&r
000
MC/DC0%0/2
not $new_key and $key =~ /$rx/
not $new_key $key =~ /$rx/
Truth table0%0/3
not(A) and B
A= not $new_keyB= $key =~ /$rx/
ABresult
0X0
100
111
339 0 $new_key = $subst->($key);
340 }
341  
342 0 ▶ if ($new_key && $new_key ne $key) {
Branch: 1 branch
BranchTrueFalseTotal
if ($new_key and $new_key ne $key) 0 0 0
Condition0%0/3
$new_key and $new_key ne $key
!ll&&!rl&&r
000
MC/DC0%0/2
$new_key and $new_key ne $key
$new_key $new_key ne $key
Truth table0%0/3
A and B
A= $new_keyB= $new_key ne $key
ABresult
0X0
100
111
343 0 ▶ if (!exists $hash->{$new_key}) {
Branch: 2 branches
BranchTrueFalseTotal
if (not exists $hash->{$new_key}) { } 0 0 0
elsif ($merge) { } 0 0 0
344 0 $hash->{$new_key} = delete $hash->{$key};
345 } elsif ($merge) {
346 0 $merge->($hash->{$new_key}, delete $hash->{$key});
347 } else {
348 0 Carp::confess("Duplicate value for key '$key' => '$new_key' without a merge function");
349 }
350 }
351  
352 0 ▶ if (ref $value) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value) 0 0 0
353 0 ▶ $value->{uq_name} = $subst->($value->{uq_name}) if $value->{uq_name};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"uq_name"} 0 0 0
354 0 ▶ $value->{file} = $subst->($value->{file}) if $value->{file};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"file"} 0 0 0
355 0 ▶ $value->{callee} = $subst->($value->{callee}) if $value->{callee};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"callee"} 0 0 0
356 0 ▶ $value->{caller} = $subst->($value->{caller}) if $value->{caller};
Branch: 1 branch
BranchTrueFalseTotal
if $value->{"caller"} 0 0 0
357 }
358 }
359 }
360  
361 0 ▶sub _merge_lines {
Subroutine _merge_lines: not called CC=4 SCAR=30.0
362 0 my ($a, $b) = @_;
363 0 ▶ my $max = $#$a > $#$b ? $#$a : $#$b;
Branch: 1 branch
BranchTrueFalseTotal
$a->$#* > $b->$#* ? : 0 0 0
364  
365 0 ▶ $a->[$_] += $b->[$_] // 0 for 0..$max;
Condition0%0/2
$b->[$_] // 0
l!l
00
MC/DC0%0/1
$b->[$_] // 0
$b->[$_]
Truth table0%0/2
A
A= $b->[$_]
Aresult
11
00
366 }
367  
368 0 ▶sub _merge_file_map_entry {
Subroutine _merge_file_map_entry: not called CC=1 SCAR=6.9
369 0 $_[0] += $_[1];
370 }
371  
372 0 ▶sub _merge_file_entry {
Subroutine _merge_file_entry: not called CC=2 SCAR=17.9
373 0 my ($a, $b) = @_;
374  
375 0 ▶ $a->{name} = $b->{name} if $a->{name} gt $b->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $a->{"name"} gt $b->{"name"} 0 0 0
376 0 $a->{exclusive} += $b->{exclusive};
377  
378 0 _merge_lines($a->{lines}{exclusive}, $b->{lines}{exclusive});
379 0 _merge_lines($a->{lines}{inclusive}, $b->{lines}{inclusive});
380 }
381  
382 0 ▶sub _merge_call_sites {
Subroutine _merge_call_sites: not called CC=1 SCAR=6.9
383 0 my ($a, $b) = @_;
384  
385 0 $a->{inclusive} += $b->{inclusive};
386 0 $a->{exclusive} += $b->{exclusive};
387 }
388  
389 0 ▶sub _merge_callees {
Subroutine _merge_callees: not called CC=1 SCAR=6.9
390 0 my ($a, $b) = @_;
391  
392 0 $a->{inclusive} += $b->{inclusive};
393 }
394  
395 0 ▶sub _merge_sub_entry {
Subroutine _merge_sub_entry: not called CC=8 SCAR=42.8
396 0 my ($a, $b) = @_;
397  
398 0 ▶ $a->{name} = $b->{name} if $a->{name} gt $b->{name};
Branch: 1 branch
BranchTrueFalseTotal
if $a->{"name"} gt $b->{"name"} 0 0 0
399  
400 0 $a->{inclusive} += $b->{inclusive};
401 0 $a->{exclusive} += $b->{exclusive};
402  
403 0 my ($acs, $bcs) = ($a->{call_sites}, $b->{call_sites});
404 0 for my $key (keys %$bcs) {
405 0 ▶ if (exists $acs->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $acs->{$key}) { } 0 0 0
406 0 $acs->{$key}{inclusive} += $bcs->{$key}{inclusive};
407 0 $acs->{$key}{exclusive} += $bcs->{$key}{exclusive};
408 } else {
409 0 $acs->{$key} = $bcs->{$key};
410 }
411 }
412  
413 0 my ($ac, $bc) = ($a->{callees}, $b->{callees});
414 0 for my $key (keys %$bc) {
415 0 ▶ if (exists $ac->{$key}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $ac->{$key}) { } 0 0 0
416 0 my ($acl, $bcl) = ($ac->{$key}, $bc->{$key});
417  
418 0 for my $sub (keys %$bcl) {
419 0 ▶ if (exists $acl->{$sub}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $acl->{$sub}) { } 0 0 0
420 0 $acl->{$sub}{inclusive} += $bcl->{$sub}{inclusive};
421 } else {
422 0 $acl->{$sub} = $bcl->{$sub};
423 }
424 }
425 } else {
426 0 $ac->{$key} = $bc->{$key};
427 }
428 }
429 }
430  
431 0 ▶sub remap_names {
Subroutine remap_names: not called CC=11 SCAR=48.8
Pod undocumented
432 0 my ($self, $exact, $prefixes) = @_;
433 0 ▶ return unless ($exact && %$exact) || ($prefixes && %$prefixes);
Branch: 1 branch
BranchTrueFalseTotal
unless $exact and %$exact or $prefixes and %$prefixes 0 0 0
Condition0%0/9
$exact and %$exact or $prefixes and %$prefixes
l!l&&r!l&&!r
000
$exact and %$exact
!ll&&!rl&&r
000
$prefixes and %$prefixes
!ll&&!rl&&r
000
MC/DC0%0/4
$exact and %$exact or $prefixes and %$prefixes
$exact %$exact $prefixes %$prefixes
Truth table0%0/7
A and B or C and D
A= $exactB= %$exactC= $prefixesD= %$prefixes
ABCDresult
11XX1
0X111
10111
0X0X0
0X100
100X0
10100
434  
435 0 my $files = $self->{aggregate}{files};
436 0 my $subs = $self->{aggregate}{subs};
437 0 my $flames = $self->{aggregate}{flames};
438  
439 0 my @exact = sort { length($b) <=> length($a) }
440 grep !/^qeval:/,
441 keys %$exact;
442 0 my @prefixes = sort { length($b) <=> length($a) } keys %$prefixes;
443  
444 0 ▶ my $file_map_rx = '(^|:|;)(?:' . join('|',
Branch: 2 branches
BranchTrueFalseTotal
@exact ? : 0 0 0
@prefixes ? : 0 0 0
445 # ((?!.)) never matches, it's there to preserve capture count
446 '(qeval:[0-9a-f]+/\(eval [0-9]+\))',
447 (@exact ? '(' . join('|', map "\Q$_\E", @exact) . ')' : '((?!.))'),
448 (@prefixes ? '(?:(' . join('|', map "\Q$_\E", @prefixes) . ')[^:;]+)' : '((?!.))'),
449 ) . ')(:|;|$)';
450 0 my $file_map_qr = qr/$file_map_rx/;
451 0 ▶ my $file_repl_sub = sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
452 0 $_[0] =~ s{$file_map_qr}
453 {$1 . (
454 $2 ? ($exact->{$2} // $2) :
455 $3 ? $exact->{$3} :
456 0 ▶ $prefixes->{$4}
Branch: 2 branches
BranchTrueFalseTotal
$2 ? : 0 0 0
$3 ? : 0 0 0
Condition0%0/3
$exact->{$2} // $2
l!l&&r!l&&!r
000
MC/DC0%0/2
$exact->{$2} // $2
$exact->{$2} $2
Truth table0%0/3
A // B
A= $exact->{$2}B= $2
ABresult
1X1
011
000
457 ) . $5}gre
458 0 };
459  
460 0 _map_hash_rx($files, $file_map_qr, $file_repl_sub, $exact, \&_merge_file_entry);
461 0 _map_hash_rx($subs, $file_map_qr, $file_repl_sub, $exact, \&_merge_sub_entry);
462  
463 0 for my $sub (values %$subs) {
464 0 _map_hash_rx($sub->{call_sites}, $file_map_qr, $file_repl_sub, $exact, \&_merge_call_sites);
465  
466 0 for my $by_line (values %{$sub->{callees}}) {
467 0 _map_hash_rx($by_line, $file_map_qr, $file_repl_sub, $exact, \&_merge_callees);
468 }
469 }
470  
471 0 for my $file (values %$files) {
472 0 ▶ _map_hash_rx($_, $file_map_qr, $file_repl_sub, $exact, sub {})
Subroutine __ANON__: not called CC=1 SCAR=0.0
473 0 for values %{$file->{subs}};
474 }
475  
476 0 _map_hash_rx($flames, $file_map_qr, $file_repl_sub, $exact, \&_merge_file_map_entry);
477 }
478  
479 6 ▶sub map_source {
Subroutine map_source: called CC=5 SCAR=19.4
Pod undocumented
480 6 my ($self) = @_;
481 6 my %eval_map;
482  
483 6 for my $file (keys %{$self->{aggregate}{files}}) {
484 88 ▶ next unless $file =~ m{^qeval:([0-9a-f]+)/(.+)$};
Branch: 1 branch
BranchTrueFalseTotal
unless $file =~ m[^qeval:([0-9a-f]+)/(.+)$] 88 0 88
485 0 my $hash = $self->{source}->get_hash_by_name($1, $2);
486  
487 0 ▶ $eval_map{$file} = "eval:$hash" if $hash;
Branch: 1 branch
BranchTrueFalseTotal
if $hash 0 0 0
488 }
489  
490 6 ▶ $self->remap_names(\%eval_map) if %eval_map;
Branch: 1 branch
BranchTrueFalseTotal
if %eval_map 0 6 6
491 }
492  
493 8781 ▶sub merge {
Subroutine merge: called CC=23 SCAR=31.5
Pod undocumented
494 8781 my ($self, $report) = @_;
495  
496 $self->_check_consistency(
497 $report->{tick},
498 $report->{perl_version},
499 $report->{process_id},
500 8781 'merged report',
501 );
502  
503 8781 $self->{aggregate}{total} += $report->{aggregate}{total};
504  
505 8781 ▶ for my $process_id (keys %{$report->{genealogy} || {}}) {
Condition50%1/2
$report->{'genealogy'} || {}
l!l
87810
MC/DC0%0/1
$report->{'genealogy'} || {}
$report->{'genealogy'}
Truth table50%1/2
A
A= $report->{'genealogy'}
Aresult
11
00
506 3960 for my $process_ordinal (keys %{$report->{genealogy}{$process_id}}) {
507 10298 ▶ $self->{genealogy}{$process_id}{$process_ordinal} ||= $report->{genealogy}{$process_id}{$process_ordinal};
Condition33%1/3
$self->{"genealogy"}{$process_id}{$process_ordinal} ||= $report->{"genealogy"}{$process_id}{$process_ordinal}
l!l&&r!l&&!r
0102980
MC/DC0%0/2
$self->{"genealogy"}{$process_id}{$process_ordinal} ||= $report->{"genealogy"}{$process_id}{$process_ordinal}
$self->{"genealogy"}{$process_id}{$process_ordinal} $report->{"genealogy"}{$process_id}{$process_ordinal}
Truth table33%1/3
A ||= B
A= $self->{"genealogy"}{$process_id}{$process_ordinal}B= $report->{"genealogy"}{$process_id}{$process_ordinal}
ABresult
1X1
011
000
508 }
509 }
510  
511 8781 $self->{metadata}->merge($report->{metadata});
512  
513 {
514 8781 my $my_subs = $self->{aggregate}{subs};
515 8781 my $other_subs = $report->{aggregate}{subs};
516  
517 8781 for my $id (keys %$other_subs) {
518 134101 my $other_sub = $other_subs->{$id};
519 my $my_sub = $my_subs->{$id} ||= {
520 name => $other_sub->{name},
521 # Compatibility with version 0.38
522 name_pretty=> $other_sub->{name_pretty} // $other_sub->{name},
523 uq_name => $other_sub->{uq_name},
524 package => $other_sub->{package},
525 file => $other_sub->{file},
526 # Compatibility with version 0.38
527 file_pretty=> $other_sub->{file_pretty} // $other_sub->{file},
528 inclusive => 0,
529 exclusive => 0,
530 callees => {},
531 call_sites => {},
532 start_line => $other_sub->{start_line},
533 uq_name => $other_sub->{uq_name},
534 kind => $other_sub->{kind},
535 is_main => $other_sub->{is_main},
536 is_eval => $other_sub->{is_eval},
537 134101 ▶ };
Condition50%4/8
$my_subs->{$id} ||= {"name", $other_sub->{"name"}, "name_pretty", $other_sub->{"name_pretty"} // $other_sub->{"name"}, "uq_name", $other_sub->{"uq_name"}, "package", $other_sub->{"package"}, "file", $other_sub->{"file"}, "file_pretty", $other_sub->{"file_pretty"} // $other_sub->{"file"}, "inclusive", 0, "exclusive", 0, "callees", {}, "call_sites", {}, "start_line", $other_sub->{"start_line"}, "uq_name", $other_sub->{"uq_name"}, "kind", $other_sub->{"kind"}, "is_main", $other_sub->{"is_main"}, "is_eval", $other_sub->{"is_eval"}}
l!l
15452118649
$other_sub->{"name_pretty"} // $other_sub->{"name"}
l!l&&r!l&&!r
11864900
$other_sub->{"file_pretty"} // $other_sub->{"file"}
l!l&&r!l&&!r
11864900
MC/DC100%1/1
$my_subs->{$id} ||= {"name", $other_sub->{"name"}, "name_pretty", $other_sub->{"name_pretty"} // $other_sub->{"name"}, "uq_name", $other_sub->{"uq_name"}, "package", $other_sub->{"package"}, "file", $other_sub->{"file"}, "file_pretty", $other_sub->{"file_pretty"} // $other_sub->{"file"}, "inclusive", 0, "exclusive", 0, "callees", {}, "call_sites", {}, "start_line", $other_sub->{"start_line"}, "uq_name", $other_sub->{"uq_name"}, "kind", $other_sub->{"kind"}, "is_main", $other_sub->{"is_main"}, "is_eval", $other_sub->{"is_eval"}}
$my_subs->{$id}
MC/DC0%0/2
$other_sub->{"name_pretty"} // $other_sub->{"name"}
$other_sub->{"name_pretty"} $other_sub->{"name"}
MC/DC0%0/2
$other_sub->{"file_pretty"} // $other_sub->{"file"}
$other_sub->{"file_pretty"} $other_sub->{"file"}
Truth table100%2/2
A
A= $my_subs->{$id}
Aresult
11
00
Truth table33%1/3
A // B
A= $other_sub->{"name_pretty"}B= $other_sub->{"name"}
ABresult
1X1
011
000
Truth table33%1/3
A // B
A= $other_sub->{"file_pretty"}B= $other_sub->{"file"}
ABresult
1X1
011
000
538  
539 134101 $my_sub->{inclusive} += $other_sub->{inclusive};
540 134101 $my_sub->{exclusive} += $other_sub->{exclusive};
541 }
542  
543 8781 for my $id (keys %$other_subs) {
544 134101 my $other_sub = $other_subs->{$id};
545 134101 my $my_sub = $my_subs->{$id};
546  
547 134101 for my $site_id (keys %{$other_sub->{call_sites}}) {
548 164772 my $other_site = $other_sub->{call_sites}{$site_id};
549 my $site = $my_sub->{call_sites}{$site_id} ||= {
550 caller => $other_site->{caller},
551 exclusive => 0,
552 inclusive => 0,
553 file => $other_site->{file},
554 line => $other_site->{line},
555 164772 ▶ };
Condition100%2/2
$my_sub->{"call_sites"}{$site_id} ||= {"caller", $other_site->{"caller"}, "exclusive", 0, "inclusive", 0, "file", $other_site->{"file"}, "line", $other_site->{"line"}}
l!l
12331152441
MC/DC100%1/1
$my_sub->{"call_sites"}{$site_id} ||= {"caller", $other_site->{"caller"}, "exclusive", 0, "inclusive", 0, "file", $other_site->{"file"}, "line", $other_site->{"line"}}
$my_sub->{"call_sites"}{$site_id}
Truth table100%2/2
A
A= $my_sub->{"call_sites"}{$site_id}
Aresult
11
00
556  
557 164772 $site->{inclusive} += $other_site->{inclusive};
558 164772 $site->{exclusive} += $other_site->{exclusive};
559 }
560  
561 134101 for my $line (keys %{$other_sub->{callees}}) {
562 135144 for my $callee_id (keys %{$other_sub->{callees}{$line}}) {
563 my $callee = $my_sub->{callees}{$line}{$callee_id} ||= {
564 callee => $other_sub->{callees}{$line}{$callee_id}{callee},
565 164772 ▶ inclusive => 0,
Condition100%2/2
$my_sub->{"callees"}{$line}{$callee_id} ||= {"callee", $other_sub->{"callees"}{$line}{$callee_id}{"callee"}, "inclusive", 0}
l!l
12331152441
MC/DC100%1/1
$my_sub->{"callees"}{$line}{$callee_id} ||= {"callee", $other_sub->{"callees"}{$line}{$callee_id}{"callee"}, "inclusive", 0}
$my_sub->{"callees"}{$line}{$callee_id}
Truth table100%2/2
A
A= $my_sub->{"callees"}{$line}{$callee_id}
Aresult
11
00
566 };
567  
568 164772 $callee->{inclusive} += $other_sub->{callees}{$line}{$callee_id}{inclusive};
569 };
570 }
571 }
572 }
573  
574 {
575 8781 my $my_files = $self->{aggregate}{files};
576 8781 my $other_files = $report->{aggregate}{files};
577  
578 8781 for my $file_id (keys %$other_files) {
579 34088 my $other_file = $other_files->{$file_id};
580 my $file = $my_files->{$file_id} ||= {
581 name => $other_file->{name},
582 report => $other_file->{report},
583 34088 ▶ lines => {
Condition100%2/2
$my_files->{$file_id} ||= {"name", $other_file->{"name"}, "report", $other_file->{"report"}, "lines", {"exclusive", [], "inclusive", []}, "exclusive", 0, "subs", {}}
l!l
798526103
MC/DC100%1/1
$my_files->{$file_id} ||= {"name", $other_file->{"name"}, "report", $other_file->{"report"}, "lines", {"exclusive", [], "inclusive", []}, "exclusive", 0, "subs", {}}
$my_files->{$file_id}
Truth table100%2/2
A
A= $my_files->{$file_id}
Aresult
11
00
584 exclusive => [],
585 inclusive => [],
586 },
587 exclusive => 0,
588 subs => {},
589 };
590  
591 34088 $file->{exclusive} += $other_file->{exclusive};
592  
593 34088 my $other_exclusive = $other_file->{lines}{exclusive};
594 34088 my $my_exclusive = $file->{lines}{exclusive};
595 34088 for my $i (0..$#$other_exclusive) {
596 6298834 ▶ $my_exclusive->[$i] += $other_exclusive->[$i]
Branch: 1 branch
BranchTrueFalseTotal
if $other_exclusive->[$i] 102469 6196365 6298834
597 if $other_exclusive->[$i];
598 }
599  
600 34088 my $other_inclusive = $other_file->{lines}{inclusive};
601 34088 my $my_inclusive = $file->{lines}{inclusive};
602 34088 for my $i (0..$#$other_inclusive) {
603 11177498 ▶ $my_inclusive->[$i] += $other_inclusive->[$i]
Branch: 1 branch
BranchTrueFalseTotal
if $other_inclusive->[$i] 220868 10956630 11177498
604 if $other_inclusive->[$i];
605 }
606  
607 34088 my $other_subs = $other_file->{subs};
608 34088 my $my_subs = $file->{subs};
609 34088 for my $line (keys %$other_subs) {
610 131722 @{$my_subs->{$line}}{keys %{$other_subs->{$line}}} = ();
611 }
612 }
613 }
614  
615 {
616 8781 my $my_flames = $self->{aggregate}{flames};
617 8781 my $other_flames = $report->{aggregate}{flames};
618  
619 8781 for my $key (keys %$other_flames) {
620 1996 $my_flames->{$key} += $other_flames->{$key};
621 }
622 }
623 }
624  
625 3350 ▶sub _save {
Subroutine _save: called CC=5 SCAR=16.6
626 3350 my ($self, $report_dir, $is_part) = @_;
627 3350 my $state_dir = state_dir($self, $is_part);
628  
629 3350 File::Path::mkpath([$state_dir, $report_dir]);
630  
631 # the merged metadata is saved separately
632 3350 ▶ if ($is_part) {
Branch: 1 branch
BranchTrueFalseTotal
if ($is_part) { } 1859 1491 3350
633 write_data_any($is_part, $self, $state_dir, 'genealogy', $self->{genealogy})
634 1859 ▶ if $self->{genealogy} && %{$self->{genealogy}};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"genealogy"} and %{$self->{"genealogy"};} 1859 0 1859
Condition33%1/3
$self->{"genealogy"} and %{$self->{"genealogy"};}
!ll&&!rl&&r
001859
MC/DC0%0/2
$self->{"genealogy"} and %{$self->{"genealogy"};}
$self->{"genealogy"} %{$self->{"genealogy"};}
Truth table33%1/3
A and B
A= $self->{"genealogy"}B= %{$self->{"genealogy"};}
ABresult
0X0
100
111
635 1859 $self->{metadata}->save_report_part($report_dir);
636 1859 ▶ $self->{source}->save_part if $self->{source};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"source"} 0 1859 1859
637 } else {
638 1491 $self->{metadata}->save_report_merged($report_dir);
639 }
640 3350 $self->_save_data($report_dir, $is_part);
641 }
642  
643 3350 ▶sub _save_data {
Subroutine _save_data: called CC=2 SCAR=6.9
644 3350 my ($self, $report_dir, $is_part) = @_;
645 my $report_base = $is_part ? sprintf('report.%s', $self->{process_id}) :
646 3350 ▶ sprintf('report.%s', $self->{suffix});
Branch: 1 branch
BranchTrueFalseTotal
$is_part ? : 1859 1491 3350
647  
648 write_data_any($is_part, $self, $report_dir, $report_base, [
649 $self->{tick},
650 $self->{stack_depth},
651 $self->{perl_version},
652 $self->{process_id},
653 $self->{aggregate}
654 3350 ]);
655 }
656  
657 1859 ▶sub save_part { $_[0]->_save($_[1], 1) }
Subroutine save_part: called CC=1 SCAR=0.0
Pod undocumented
658 1491 ▶sub save_aggregate { $_[0]->_save($_[1], 0) }
Subroutine save_aggregate: called CC=1 SCAR=0.0
Pod undocumented
659  
660 3340 ▶sub load {
Subroutine load: called CC=1 SCAR=0.0
Pod undocumented
661 3340 my ($self, $report) = @_;
662  
663 3340 @{$self}{qw(
664 tick
665 stack_depth
666 perl_version
667 process_id
668 aggregate
669 3340 )} = @{read_data($self->{serializer}, $report)};
670 }
671  
672 377 ▶sub load_and_merge_metadata {
Subroutine load_and_merge_metadata: called CC=1 SCAR=0.0
Pod undocumented
673 377 my ($self, $metadata) = @_;
674  
675 377 $self->{metadata}->load_and_merge($metadata);
676 }
677  
678 9 ▶sub metadata {
Subroutine metadata: called CC=1 SCAR=0.0
Pod undocumented
679 9 my ($self) = @_;
680  
681 9 return $self->{metadata}->get;
682 }
683  
684 727 ▶sub add_metadata {
Subroutine add_metadata: called CC=1 SCAR=0.0
Pod undocumented
685 727 my ($self, $metadata) = @_;
686  
687 727 $self->{metadata}->add_entries($metadata);
688 }
689  
690 8342 ▶sub _fileify {
Subroutine _fileify: called CC=2 SCAR=7.0
691 8342 my ($name) = @_;
692  
693 8342 ▶ return 'no-file' unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 8342 8342
694 8342 my $base = File::Basename::basename($name) =~ s/\W+/-/gr;
695 8342 my $id = substr(utf8_sha1_hex($name), 0, 20);
696  
697 8342 return "$base-$id";
698 }
699  
700 0 ▶sub finalize { } # stub for backwards compatibility
Subroutine finalize: not called CC=1 SCAR=0.0
Pod undocumented
701  
702 2 ▶sub fetch_source_from_file {
Subroutine fetch_source_from_file: called CC=2 SCAR=7.2
Pod undocumented
703 2 my ($self, $path) = @_;
704  
705 2 ▶ return -f $path ? $path : undef;
Branch: 1 branch
BranchTrueFalseTotal
-f $path ? : 2 0 2
706 }
707  
708 2 ▶sub _fetch_source {
Subroutine _fetch_source: called CC=21 SCAR=40.0
709 2 my ($self, $path, $fetchers) = @_;
710 2 my @lines;
711  
712 # synthesized XS entries
713 2 ▶ if ($path =~ /^xs:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /^xs:/) 0 2 2
714 0 return [], ['Dummy file to stick orphan XSUBs in...'];
715 }
716  
717 # unmapped evals
718 2 ▶ if ($path =~ /^qeval:/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /^qeval:/) 0 2 2
719 0 return [], $NO_SOURCE;
720 }
721  
722 # eval source code
723 2 ▶ if ($self->{source} && $path =~ /^eval:([0-9a-fA-F]+)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"source"} and $path =~ /^eval:([0-9a-fA-F]+)$/) 0 2 2
Condition33%1/3
$self->{"source"} and $path =~ /^eval:([0-9a-fA-F]+)$/
!ll&&!rl&&r
020
MC/DC0%0/2
$self->{"source"} and $path =~ /^eval:([0-9a-fA-F]+)$/
$self->{"source"} $path =~ /^eval:([0-9a-fA-F]+)$/
Truth table33%1/3
A and B
A= $self->{"source"}B= $path =~ /^eval:([0-9a-fA-F]+)$/
ABresult
0X0
100
111
724 0 ▶ if (my $source = $self->{source}->get_source_by_hash($1)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $source = $self->{"source"}->get_source_by_hash($1)) 0 0 0
725 0 return [], ['Eval source code...', split /\n/, $source];
726 }
727 }
728  
729 2 my ($input, $fh);
730 2 ▶ for my $fetcher (@{$fetchers // $self->{fetchers}}) {
Condition33%1/3
$fetchers // $self->{"fetchers"}
l!l&&r!l&&!r
020
MC/DC0%0/2
$fetchers // $self->{"fetchers"}
$fetchers $self->{"fetchers"}
Truth table33%1/3
A // B
A= $fetchersB= $self->{"fetchers"}
ABresult
1X1
011
000
731 2 my ($prefix, $code) = @$fetcher;
732  
733 2 ▶ next if $prefix && rindex($path, $prefix, 0) == -1;
Branch: 1 branch
BranchTrueFalseTotal
if $prefix and rindex($path, $prefix, 0) == -1 0 2 2
Condition33%1/3
$prefix and rindex($path, $prefix, 0) == -1
!ll&&!rl&&r
200
MC/DC0%0/2
$prefix and rindex($path, $prefix, 0) == -1
$prefix rindex($path, $prefix, 0) == -1
Truth table33%1/3
A and B
A= $prefixB= rindex($path, $prefix, 0) == -1
ABresult
0X0
100
111
734 2 ▶ $input = ref($code) eq 'CODE' ? $code->($path) : $self->$code($path);
Branch: 1 branch
BranchTrueFalseTotal
ref $code eq 'CODE' ? : 0 2 2
735 2 ▶ last if $input;
Branch: 1 branch
BranchTrueFalseTotal
if $input 2 0 2
736 }
737 2 ▶ return [], $NO_SOURCE unless $input;
Branch: 1 branch
BranchTrueFalseTotal
unless $input 0 2 2
738  
739 2 ▶ if (my $ref = ref($input)) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ref = ref $input) { } 0 2 2
740 0 ▶ if ($ref eq 'SCALAR') {
Branch: 2 branches
BranchTrueFalseTotal
if ($ref eq 'SCALAR') { } 0 0 0
elsif ($ref eq 'GLOB') { } 0 0 0
741 0 open $fh, '<', $input;
742 } elsif ($ref eq 'GLOB') {
743 0 $fh = $input;
744 } else {
745 0 die "Source code fetcher returned reference to '$ref', "
746 . " expected either 'SCALAR' or 'GLOB'";
747 }
748 } else {
749 2 ▶ open $fh, '<', $input
Branch: 1 branch
BranchTrueFalseTotal
&Devel::StatProfiler::Report::open($fh, "<", $input) or die "Failed to open source code file '${input}' for path '${path}', " . "do you have permission to read it? (Reason: $!)" 2 0 2
750 or die "Failed to open source code file '$input' for path '$path', "
751 . "do you have permission to read it? (Reason: $!)";
752 }
753  
754 2 $self->{sourcemap}->start_file_mapping($path);
755  
756 2 my @ends;
757 2 ▶ while (defined (my $line = <$fh>)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $line = readline $fh)) 404 2 406
758 404 ▶ $self->{sourcemap}->add_file_mapping(@lines + 2, $2, $1)
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /^#line\s+(\d+)\s+(.+)$/ 4 400 404
759 if $line =~ /^#line\s+(\d+)\s+(.+)$/;
760 404 push @lines, $line;
761 404 ▶ push @ends, scalar @lines if $line =~ /\b__(?:DATA|END)__\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $line =~ /\b__(?:DATA|END)__\b/ 0 404 404
762 }
763  
764 2 $self->{sourcemap}->end_file_mapping(scalar @lines);
765  
766 2 ▶ return [], $NO_SOURCE unless @lines;
Branch: 1 branch
BranchTrueFalseTotal
unless @lines 0 2 2
767 2 return \@ends, ['I hope you never see this...', @lines];
768 }
769  
770 # merges the entries for multiple logical files to match the source
771 # code of a physical file
772 0 ▶sub _merged_entry {
Subroutine _merged_entry: not called CC=18 SCAR=58.3
773 0 my ($self, $file, $mapping, $diagnostics) = @_;
774 # we need to ensure the merged entry is created with the correct metadata
775 # (especially the report file)
776 0 my $base = $self->{aggregate}{files}{$file};
777 my $merged = {
778 name => $base && $base->{name},
779 lines => {
780 exclusive => [],
781 inclusive => [],
782 },
783 report => $base && $base->{report},
784 0 ▶ exclusive => 0,
Condition0%0/6
$base && $base->{'name'}
!ll&&!rl&&r
000
$base && $base->{'report'}
!ll&&!rl&&r
000
MC/DC0%0/2
$base && $base->{'name'}
$base $base->{'name'}
MC/DC0%0/2
$base && $base->{'report'}
$base $base->{'report'}
Truth table0%0/3
A && B
A= $baseB= $base->{'name'}
ABresult
0X0
100
111
Truth table0%0/3
A && B
A= $baseB= $base->{'report'}
ABresult
0X0
100
111
785 subs => {},
786 };
787 0 my $merged_callees = {};
788 0 my %line_ranges;
789  
790 0 ▶ for (my $i = 0; $i < $#$mapping; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $mapping->$#*) 0 0 0
791 0 my ($physical_line, $logical_file, $logical_line) = @{$mapping->[$i]};
792 0 my $physical_end = $mapping->[$i + 1][0];
793  
794 0 push @{$line_ranges{$logical_file}}, [
795 $logical_line,
796 $logical_line + $physical_end - $physical_line,
797 $physical_line,
798 $physical_end,
799 ];
800 }
801  
802 0 for my $key (keys %line_ranges) {
803 0 my $entry = $self->{aggregate}{files}{$key};
804  
805 # we have no data for this part of the file
806 0 ▶ next unless $entry;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry 0 0 0
807  
808 0 ▶ $merged->{name} ||= $entry->{name};
Condition0%0/3
$merged->{"name"} ||= $entry->{"name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$merged->{"name"} ||= $entry->{"name"}
$merged->{"name"} $entry->{"name"}
Truth table0%0/3
A ||= B
A= $merged->{"name"}B= $entry->{"name"}
ABresult
1X1
011
000
809 0 ▶ $merged->{report} ||= $entry->{report};
Condition0%0/3
$merged->{"report"} ||= $entry->{"report"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$merged->{"report"} ||= $entry->{"report"}
$merged->{"report"} $entry->{"report"}
Truth table0%0/3
A ||= B
A= $merged->{"report"}B= $entry->{"report"}
ABresult
1X1
011
000
810  
811 0 my @ranges = sort { $a->[1] <=> $b->[1] } @{$line_ranges{$key}};
812 0 my @subs = sort { $a <=> $b } keys %{$entry->{subs}};
813 0 my $entry_callees = $self->_callees_by_file($entry);
814 0 my @callees = sort { $a <=> $b } keys %$entry_callees;
815 0 my ($sub_index, $callee_index) = (0, 0);
816  
817 0 $merged->{exclusive} += $entry->{exclusive};
818  
819 0 for my $range (@ranges) {
820 0 my ($logical_start, $logical_end, $physical_start, $physical_end) =
821 @$range;
822  
823 0 ▶ while ($sub_index < @subs && $subs[$sub_index] <= $logical_end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub_index < @subs and $subs[$sub_index] <= $logical_end) 0 0 0
Condition0%0/3
$sub_index < @subs and $subs[$sub_index] <= $logical_end
!ll&&!rl&&r
000
MC/DC0%0/2
$sub_index < @subs and $subs[$sub_index] <= $logical_end
$sub_index < @subs $subs[$sub_index] <= $logical_end
Truth table0%0/3
A and B
A= $sub_index < @subsB= $subs[$sub_index] <= $logical_end
ABresult
0X0
100
111
824 0 my $mapped = $subs[$sub_index] - $logical_start + $physical_start;
825  
826 0 $merged->{subs}{$mapped} = $entry->{subs}{$subs[$sub_index]};
827 0 ++$sub_index;
828 }
829  
830 0 ▶ while ($callee_index < @callees && $callees[$callee_index] <= $logical_end) {
Branch: 1 branch
BranchTrueFalseTotal
if ($callee_index < @callees and $callees[$callee_index] <= $logical_end) 0 0 0
Condition0%0/3
$callee_index < @callees and $callees[$callee_index] <= $logical_end
!ll&&!rl&&r
000
MC/DC0%0/2
$callee_index < @callees and $callees[$callee_index] <= $logical_end
$callee_index < @callees $callees[$callee_index] <= $logical_end
Truth table0%0/3
A and B
A= $callee_index < @calleesB= $callees[$callee_index] <= $logical_end
ABresult
0X0
100
111
831 0 my $mapped = $callees[$callee_index] - $logical_start + $physical_start;
832  
833 0 $merged_callees->{$mapped} = $entry_callees->{$callees[$callee_index]};
834 0 ++$callee_index;
835 }
836  
837 0 for my $logical_line ($logical_start .. $logical_end) {
838 0 my $physical_line = $logical_line - $logical_start + $physical_start;
839  
840 0 ▶ $merged->{lines}{inclusive}[$physical_line] += $entry->{lines}{inclusive}[$logical_line] // 0;
Condition0%0/2
$entry->{"lines"}{"inclusive"}[$logical_line] // 0
l!l
00
MC/DC0%0/1
$entry->{"lines"}{"inclusive"}[$logical_line] // 0
$entry->{"lines"}{"inclusive"}[$logical_line]
Truth table0%0/2
A
A= $entry->{"lines"}{"inclusive"}[$logical_line]
Aresult
11
00
841 0 ▶ $merged->{lines}{exclusive}[$physical_line] += $entry->{lines}{exclusive}[$logical_line] // 0;
Condition0%0/2
$entry->{"lines"}{"exclusive"}[$logical_line] // 0
l!l
00
MC/DC0%0/1
$entry->{"lines"}{"exclusive"}[$logical_line] // 0
$entry->{"lines"}{"exclusive"}[$logical_line]
Truth table0%0/2
A
A= $entry->{"lines"}{"exclusive"}[$logical_line]
Aresult
11
00
842 }
843 }
844  
845 0 ▶ push @$diagnostics, "There are unmapped subs for '$key' in '$file'"
Branch: 1 branch
BranchTrueFalseTotal
unless $sub_index == @subs 0 0 0
846 unless $sub_index == @subs;
847 0 ▶ push @$diagnostics, "There are unmapped callees for '$key' in '$file'"
Branch: 1 branch
BranchTrueFalseTotal
unless $callee_index == @callees 0 0 0
848 unless $callee_index == @callees;
849 }
850  
851 0 return ($merged, $merged_callees);
852 }
853  
854 0 ▶sub _format_ratio {
Subroutine _format_ratio: not called CC=11 SCAR=48.8
855 0 my ($value, $total, $empty) = @_;
856 0 ▶ $value //= 0, $total //= 0;
Condition0%0/4
$value //= 0
l!l
00
$total //= 0
l!l
00
MC/DC0%0/1
$value //= 0
$value
MC/DC0%0/1
$total //= 0
$total
Truth table0%0/2
A
A= $value
Aresult
11
00
Truth table0%0/2
A
A= $total
Aresult
11
00
857  
858 0 ▶ return '' if $empty && $value == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $empty and $value == 0 0 0 0
Condition0%0/3
$empty and $value == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$empty and $value == 0
$empty $value == 0
Truth table0%0/3
A and B
A= $emptyB= $value == 0
ABresult
0X0
100
111
859 0 ▶ return '0' if $value == 0 && $total == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $value == 0 and $total == 0 0 0 0
Condition0%0/3
$value == 0 and $total == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$value == 0 and $total == 0
$value == 0 $total == 0
Truth table0%0/3
A and B
A= $value == 0B= $total == 0
ABresult
0X0
100
111
860 0 ▶ return '? (?%)' if $value != 0 && $total == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $value != 0 and $total == 0 0 0 0
Condition0%0/3
$value != 0 and $total == 0
!ll&&!rl&&r
000
MC/DC0%0/2
$value != 0 and $total == 0
$value != 0 $total == 0
Truth table0%0/3
A and B
A= $value != 0B= $total == 0
ABresult
0X0
100
111
861  
862 0 my $perc = $value / $total * 100;
863 0 ▶ if ($perc >= 0.01) {
Branch: 2 branches
BranchTrueFalseTotal
if ($perc >= 0.01) { } 0 0 0
elsif ($perc >= 0.0001) { } 0 0 0
864 0 return sprintf '%d (%.02f%%)', $value, $perc;
865 } elsif ($perc >= 0.0001) {
866 0 return sprintf '%d (%.04f%%)', $value, $perc;
867 } else {
868 0 return sprintf '%d', $value;
869 }
870 }
871  
872 0 ▶sub _callees_by_file {
Subroutine _callees_by_file: not called CC=3 SCAR=24.8
873 0 my ($self, $file_entry) = @_;
874 0 my $callees = {};
875  
876 0 for my $sub_name (map keys %$_, values %{$file_entry->{subs}}) {
877 0 my $sub = $self->{aggregate}{subs}{$sub_name};
878 0 my $sub_callees = $sub->{callees};
879  
880 0 for my $line (keys %$sub_callees) {
881 0 push @{$callees->{$line}}, values %{$sub_callees->{$line}};;
882 }
883 }
884  
885 0 return $callees;
886 }
887  
888 0 ▶sub start_flamegraphs {
Subroutine start_flamegraphs: not called CC=4 SCAR=30.0
Pod undocumented
889 0 my ($self, $attributes, $directory, $compress) = @_;
890 0 my $flames = $self->{aggregate}{flames};
891 0 my $calls_data = File::Spec::Functions::catfile($directory, 'all_stacks_by_time.calls');
892 0 my $clickable_nameattr = File::Spec::Functions::catfile($directory, 'clickable_stacks.attrs');
893 0 my $zoomable_nameattr = File::Spec::Functions::catfile($directory, 'zoomable_stacks.attrs');
894  
895 0 ▶ open my $calls_fh, '>', $calls_data or die "Unable to open '$calls_data': $!";
Branch: 1 branch
BranchTrueFalseTotal
&Devel::StatProfiler::Report::open(my $calls_fh, ">", $calls_data) or die "Unable to open '${calls_data}': $!" 0 0 0
896 0 for my $key (keys %$flames) {
897 0 print $calls_fh $key, ' ', $flames->{$key}, "\n";
898 }
899 0 ▶ close $calls_fh or die "Unable to close '$calls_data': $!";
Branch: 1 branch
BranchTrueFalseTotal
&Devel::StatProfiler::Report::close($calls_fh) or die "Unable to close '${calls_data}': $!" 0 0 0
900  
901 0 Devel::StatProfiler::FlameGraph->write_attributes(
902 $clickable_nameattr, $attributes,
903 );
904 0 Devel::StatProfiler::FlameGraph->write_attributes(
905 $zoomable_nameattr, $attributes, 'zoomable',
906 );
907  
908 my $clickable = Devel::StatProfiler::FlameGraph->new(
909 directory => $directory,
910 traces => 'all_stacks_by_time.calls',
911 output => 'clickable_stacks_by_time.svg',
912 attributes => 'clickable_stacks.attrs',
913 args => {
914 total => $self->{aggregate}{total},
915 0 title => "Flame Graph",
916 },
917 );
918 my $zoomable = Devel::StatProfiler::FlameGraph->new(
919 directory => $directory,
920 traces => 'all_stacks_by_time.calls',
921 output => 'zoomable_stacks_by_time.svg',
922 attributes => 'zoomable_stacks.attrs',
923 args => {
924 total => $self->{aggregate}{total},
925 0 title => "Zoomable Flame Graph",
926 },
927 );
928  
929 0 $clickable->start;
930 0 $zoomable->start;
931  
932 return {
933 0 clickable => $clickable,
934 zoomable => $zoomable,
935 compress => $compress,
936 };
937 }
938  
939 0 ▶sub complete_flamegraphs {
Subroutine complete_flamegraphs: not called CC=4 SCAR=30.0
Pod undocumented
940 0 my ($self, $state) = @_;
941  
942 0 $state->{clickable}->wait;
943 0 $state->{zoomable}->wait;
944  
945 0 ▶ if ($state->{compress}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($state->{"compress"}) 0 0 0
946 0 for my $file (@{$state->{clickable}->all_files},
947 0 @{$state->{zoomable}->all_files}) {
948 0 ▶ $self->_compress_inplace($file) if -f $file;
Branch: 1 branch
BranchTrueFalseTotal
if -f $file 0 0 0
949 }
950 }
951  
952 0 return $state;
953 }
954  
955 0 ▶sub output {
Subroutine output: not called CC=28 SCAR=67.0
Pod undocumented
956 0 my ($self, $directory, $compress, $fetchers) = @_;
957 0 my @diagnostics;
958  
959 die "Unable to create report without a source map and an eval map"
960 0 ▶ unless $self->{source} and $self->{sourcemap};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"source"} and $self->{"sourcemap"} 0 0 0
Condition0%0/3
$self->{"source"} and $self->{"sourcemap"}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"source"} and $self->{"sourcemap"}
$self->{"source"} $self->{"sourcemap"}
Truth table0%0/3
A and B
A= $self->{"source"}B= $self->{"sourcemap"}
ABresult
0X0
100
111
961  
962 0 File::Path::mkpath([$directory]);
963  
964 0 my $files = $self->{aggregate}{files};
965 my @subs = sort { $b->{exclusive} <=> $a->{exclusive} ||
966 0 ▶ $b->{inclusive} <=> $a->{inclusive} }
Condition0%0/3
$Devel::StatProfiler::Report::b->{'exclusive'} <=> $Devel::StatProfiler::Report::a->{'exclusive'} || $Devel::StatProfiler::Report::b->{'inclusive'} <=> $Devel::StatProfiler::Report::a->{'inclusive'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Devel::StatProfiler::Report::b->{'exclusive'} <=> $Devel::StatProfiler::Report::a->{'exclusive'} || $Devel::StatProfiler::Report::b->{'inclusive'} <=> $Devel::StatProfiler::Report::a->{'inclusive'}
$Devel::StatProfiler::Report::b->{'exclusive'} <=> $Devel::StatProfiler::Report::a->{'exclusive'} $Devel::StatProfiler::Report::b->{'inclusive'} <=> $Devel::StatProfiler::Report::a->{'inclusive'}
Truth table0%0/3
A || B
A= $Devel::StatProfiler::Report::b->{'exclusive'} <=> $Devel::StatProfiler::Report::a->{'exclusive'}B= $Devel::StatProfiler::Report::b->{'inclusive'} <=> $Devel::StatProfiler::Report::a->{'inclusive'}
ABresult
1X1
011
000
967 0 values %{$self->{aggregate}{subs}};
968 0 my @files = sort { $b->{exclusive} <=> $a->{exclusive} }
969 values %$files;
970  
971 # Backwards compatibility for releases before 0.40
972 0 ▶ $_->{file_pretty} //= $_->{file} for @subs;
Condition0%0/3
$_->{"file_pretty"} //= $_->{"file"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{"file_pretty"} //= $_->{"file"}
$_->{"file_pretty"} $_->{"file"}
Truth table0%0/3
A //= B
A= $_->{"file_pretty"}B= $_->{"file"}
ABresult
1X1
011
000
973 0 ▶ $_->{name_pretty} //= $_->{name} for @subs;
Condition0%0/3
$_->{"name_pretty"} //= $_->{"name"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$_->{"name_pretty"} //= $_->{"name"}
$_->{"name_pretty"} $_->{"name"}
Truth table0%0/3
A //= B
A= $_->{"name_pretty"}B= $_->{"name"}
ABresult
1X1
011
000
974  
975 0 my $date = POSIX::strftime('%c', localtime(time));
976 0 my $at_inc = [map s{[/\\]$}{}r, @{$self->{metadata}->get_at_inc}];
977 0 ▶ my $include = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
978 0 $TEMPLATES{$_[0]}->($_[1]);
979 0 };
980  
981 0 ▶ my $sub_link = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
982 0 my ($sub) = @_;
983  
984 0 ▶ if ($sub->{kind} == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub->{'kind'} == 0) { } 0 0 0
985 return sprintf '%s#S%s',
986 $self->{aggregate}{files}{$sub->{file}}{report},
987 0 $sub->{uq_name} =~ s/\W+/-/gr;
988 } else {
989 return sprintf '%s#S%s',
990 $self->{aggregate}{files}{$sub->{file}}{report},
991 0 $sub->{name} =~ s/\W+/-/gr;
992 }
993 0 };
994  
995 0 ▶ my $file_name = sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
996 0 ▶ return $1 if $_[0] =~ m{qeval:[0-9a-f]+/(.+)$};
Branch: 1 branch
BranchTrueFalseTotal
if $_[0] =~ m[qeval:[0-9a-f]+/(.+)$] 0 0 0
997  
998 0 for my $dir (@$at_inc) {
999 0 ▶ return substr $_[0], length($dir) + 1
Branch: 1 branch
BranchTrueFalseTotal
if rindex($_[0], $dir, 0) == 0 and substr($_[0], length $dir, 1) =~ m([/\\]) 0 0 0
Condition0%0/3
rindex($_[0], $dir, 0) == 0 and substr($_[0], length $dir, 1) =~ m([/\\])
!ll&&!rl&&r
000
MC/DC0%0/2
rindex($_[0], $dir, 0) == 0 and substr($_[0], length $dir, 1) =~ m([/\\])
rindex($_[0], $dir, 0) == 0 substr($_[0], length $dir, 1) =~ m([/\\])
Truth table0%0/3
A and B
A= rindex($_[0], $dir, 0) == 0B= substr($_[0], length $dir, 1) =~ m([/\\])
ABresult
0X0
100
111
1000 if rindex($_[0], $dir, 0) == 0 && substr($_[0], length($dir), 1) =~ m{[/\\]};
1001 }
1002  
1003 0 return $_[0];
1004 0 };
1005  
1006 0 ▶ my $file_link = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1007 0 my ($file, $line) = @_;
1008 0 my $report = $self->{aggregate}{files}{$file}{report};
1009  
1010 # twice, because we have physical files with source code for
1011 # multiple logical files (via #line directives)
1012 0 return sprintf '%s#L%s-%d', $report, $report, $line;
1013 0 };
1014  
1015 0 ▶ my $sub_name = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1016 0 ▶ return $_[0] if $_[0] !~ m{[/\\]};
Branch: 1 branch
BranchTrueFalseTotal
unless $_[0] =~ m([/\\]) 0 0 0
1017 0 return $file_name->($_[0]);
1018 0 };
1019  
1020 0 ▶ my $lookup_sub = sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
1021 0 my ($name) = @_;
1022  
1023 0 ▶ die "Invalid sub reference '$name'" unless exists $self->{aggregate}{subs}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"aggregate"}{"subs"}{$name} 0 0 0
1024 0 return $self->{aggregate}{subs}{$name};
1025 0 };
1026  
1027 0 ▶ my $format_total_samples = sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
1028 0 my ($samples, $empty) = @_;
1029  
1030 0 return _format_ratio($samples, $self->{aggregate}{total}, $empty);
1031 0 };
1032  
1033 # format files
1034 0 ▶ my $format_file = sub {
Subroutine __ANON__: not called CC=21 SCAR=61.4
1035 0 my ($entry, $ends, $code, $callees, $mapping) = @_;
1036 # map logical line, physical file, physical line ->
1037 # logical line, HTML report file, physical line
1038 my $mapping_for_link = [map {
1039 0 [$_->[0],
1040 ($_->[1] && $self->{aggregate}{files}{$_->[1]} ?
1041 $self->{aggregate}{files}{$_->[1]}{report} :
1042 0 ▶ undef),
Branch: 1 branch
BranchTrueFalseTotal
$_->[1] && $self->{'aggregate'}{'files'}{$_->[1]} ? : 0 0 0
Condition0%0/3
$_->[1] and $self->{"aggregate"}{"files"}{$_->[1]}
!ll&&!rl&&r
000
MC/DC0%0/2
$_->[1] and $self->{"aggregate"}{"files"}{$_->[1]}
$_->[1] $self->{"aggregate"}{"files"}{$_->[1]}
Truth table0%0/3
A and B
A= $_->[1]B= $self->{"aggregate"}{"files"}{$_->[1]}
ABresult
0X0
100
111
1043 $_->[2]]
1044 } @$mapping];
1045  
1046 # find actual sub definition by matching source name in code
1047 # (yes, fragile, but mostly good enough)
1048 0 my %subs;
1049 0 for my $subs_at_line (values %{$entry->{subs}}) {
1050 0 for my $uq_name (keys %$subs_at_line) {
1051 0 ▶ my $sub = $self->{aggregate}{subs}{$uq_name} //
Condition0%0/2
$self->{"aggregate"}{"subs"}{$uq_name} // die("Unable to find sub '${uq_name}'")
l!l
00
MC/DC0%0/1
$self->{"aggregate"}{"subs"}{$uq_name} // die("Unable to find sub '${uq_name}'")
$self->{"aggregate"}{"subs"}{$uq_name}
Truth table0%0/2
A
A= $self->{"aggregate"}{"subs"}{$uq_name}
Aresult
11
00
1052 die "Unable to find sub '$uq_name'";
1053 0 ▶ if ($sub->{is_main} || $sub->{is_eval}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($sub->{"is_main"} or $sub->{"is_eval"}) 0 0 0
Condition0%0/3
$sub->{"is_main"} or $sub->{"is_eval"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$sub->{"is_main"} or $sub->{"is_eval"}
$sub->{"is_main"} $sub->{"is_eval"}
Truth table0%0/3
A or B
A= $sub->{"is_main"}B= $sub->{"is_eval"}
ABresult
1X1
011
000
1054 0 ▶ push @{$subs{1}}, $sub if $sub->{is_eval};
Branch: 1 branch
BranchTrueFalseTotal
if $sub->{"is_eval"} 0 0 0
1055 0 next;
1056 }
1057 0 my $fq_name = $sub->{name};
1058 0 my $name = $fq_name =~ s{.*::}{}r;
1059  
1060 # finding the start of anonymous subs is way too fragile,
1061 # just use the default
1062 0 ▶ if ($name eq '__ANON__') {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "__ANON__") 0 0 0
1063 0 push @{$subs{$sub->{start_line}}}, $sub;
1064 0 next;
1065 }
1066  
1067 0 ▶ my $match = $SPECIAL_SUBS{$name} ?
Branch: 1 branch
BranchTrueFalseTotal
$SPECIAL_SUBS{$name} ? : 0 0 0
1068 qr{\bsub\s+(?:\Q$fq_name\E|\Q$name\E)\b|^\s*\Q$name\E\b} :
1069 qr{\bsub\s+(?:\Q$fq_name\E|\Q$name\E)\b};
1070 # TODO move this code to _merged_entry
1071 0 my $start_line = $sub->{start_line};
1072 0 ▶ for (my $i = 0; $i < @$mapping; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @$mapping) 0 0 0
1073 0 my $entry = $mapping->[$i];
1074 0 ▶ next unless $entry->[1] && $entry->[1] eq $sub->{file};
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->[1] and $entry->[1] eq $sub->{"file"} 0 0 0
Condition0%0/3
$entry->[1] and $entry->[1] eq $sub->{"file"}
!ll&&!rl&&r
000
MC/DC0%0/2
$entry->[1] and $entry->[1] eq $sub->{"file"}
$entry->[1] $entry->[1] eq $sub->{"file"}
Truth table0%0/3
A and B
A= $entry->[1]B= $entry->[1] eq $sub->{"file"}
ABresult
0X0
100
111
1075 0 ▶ if ($entry->[2] <= $start_line && ($entry->[2] + ($mapping->[$i + 1][0] - $entry->[0])) > $start_line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($entry->[2] <= $start_line and $entry->[2] + ($$mapping[$i + 1][0] - $entry->[0]) > $start_line) 0 0 0
Condition0%0/3
$entry->[2] <= $start_line and $entry->[2] + ($$mapping[$i + 1][0] - $entry->[0]) > $start_line
!ll&&!rl&&r
000
MC/DC0%0/2
$entry->[2] <= $start_line and $entry->[2] + ($$mapping[$i + 1][0] - $entry->[0]) > $start_line
$entry->[2] <= $start_line $entry->[2] + ($$mapping[$i + 1][0] - $entry->[0]) > $start_line
Truth table0%0/3
A and B
A= $entry->[2] <= $start_lineB= $entry->[2] + ($$mapping[$i + 1][0] - $entry->[0]) > $start_line
ABresult
0X0
100
111
1076 0 $start_line = $entry->[0] + $start_line - $entry->[2];
1077 }
1078 }
1079 0 ▶ for (my $line = $start_line; $line > 0 && $line < @$code; --$line) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line > 0 and $line < @$code) 0 0 0
Condition0%0/3
$line > 0 and $line < @$code
!ll&&!rl&&r
000
MC/DC0%0/2
$line > 0 and $line < @$code
$line > 0 $line < @$code
Truth table0%0/3
A and B
A= $line > 0B= $line < @$code
ABresult
0X0
100
111
1080 0 my $src = $code->[$line];
1081  
1082 0 ▶ if ($src =~ $match) {
Branch: 1 branch
BranchTrueFalseTotal
if ($src =~ /$match/) 0 0 0
1083 0 $start_line = $line;
1084 0 last;
1085 }
1086 }
1087  
1088 0 push @{$subs{$start_line}}, $sub;
1089 }
1090 }
1091  
1092 # remove source after __DATA__/__END__ token, but only if
1093 # there are no samples after it (to avoid false positives)
1094 0 for my $end (@$ends) {
1095 0 ▶ if ($end >= @{$entry->{lines}{inclusive}} - 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($end >= @{$entry->{"lines"}{"inclusive"};} - 1) 0 0 0
1096 0 splice @$code, $end + 1; # preserve the __DATA__/__END__
1097 0 last;
1098 }
1099 }
1100  
1101 my %file_data = (
1102 include => $include,
1103 date => $date,
1104 name => $entry->{name},
1105 lines => $code,
1106 subs => \%subs,
1107 exclusive => $entry->{lines}{exclusive},
1108 inclusive => $entry->{lines}{inclusive},
1109 0 callees => $callees,
1110 sub_link => $sub_link,
1111 sub_name => $sub_name,
1112 file_name => $file_name,
1113 file_link => $file_link,
1114 format_total_ratio => $format_total_samples,
1115 format_ratio => \&_format_ratio,
1116 lookup_sub => $lookup_sub,
1117 mapping => $mapping_for_link,
1118 );
1119  
1120 $self->_write_template($TEMPLATES{file}, \%file_data,
1121 0 $directory, $entry->{report}, $compress);
1122 0 };
1123  
1124 # write reports for physical files
1125 0 my %extra_reverse_files;
1126 0 my (@first_pass, @second_pass) = (keys %$files);
1127  
1128 0 @extra_reverse_files{@first_pass} = ();
1129 0 ▶ while (@first_pass) {
Branch: 1 branch
BranchTrueFalseTotal
if (@first_pass) 0 0 0
1130 0 my $file = shift @first_pass;
1131 0 my ($ends, $code) = $self->_fetch_source($file, $fetchers);
1132  
1133 # TODO merge xs:<file> with real file entry, if there is one
1134 0 ▶ if ($code eq $NO_SOURCE) {
Branch: 2 branches
BranchTrueFalseTotal
if ($code eq $NO_SOURCE) { } 0 0 0
elsif (my $mapping = $self->{'sourcemap'}->get_mapping($file)) { } 0 0 0
1135 0 my $reverse_file = $self->{sourcemap}->get_reverse_mapping($file);
1136  
1137 # if there are files/evals where the "principal" part did not
1138 # get any samples, but some of the other parts (mapped by
1139 # #line directives) got some samples, ensure we render the
1140 # "principal" part, so it can be used as the source of the copy
1141 # in the loop below
1142 0 ▶ if ($reverse_file &&
Branch: 1 branch
BranchTrueFalseTotal
if ($reverse_file and $reverse_file =~ /eval:/ and not $files->{$reverse_file} and not exists $extra_reverse_files{$reverse_file}) 0 0 0
Condition0%0/9
$reverse_file and $reverse_file =~ /eval:/ and not $files->{$reverse_file} and not exists $extra_reverse_files{$reverse_file}
!ll&&!rl&&r
000
$reverse_file and $reverse_file =~ /eval:/ and not $files->{$reverse_file}
!ll&&!rl&&r
000
$reverse_file and $reverse_file =~ /eval:/
!ll&&!rl&&r
000
MC/DC0%0/4
$reverse_file and $reverse_file =~ /eval:/ and not $files->{$reverse_file} and not exists $extra_reverse_files{$reverse_file}
$reverse_file $reverse_file =~ /eval:/ not $files->{$reverse_file} not exists $extra_reverse_files{$reverse_file}
Truth table0%0/5
A and B and not(C) and not(D)
A= $reverse_fileB= $reverse_file =~ /eval:/C= not $files->{$reverse_file}D= not exists $extra_reverse_files{$reverse_file}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
1143 $reverse_file =~ /eval:/ &&
1144 !$files->{$reverse_file} &&
1145 !exists $extra_reverse_files{$reverse_file}) {
1146 0 $extra_reverse_files{$reverse_file} = undef;
1147 0 push @first_pass, $reverse_file;
1148 }
1149  
1150 # re-process this later, in case the mapping is due to a
1151 # #line directive in one of the parsed files
1152 0 push @second_pass, $file;
1153 } elsif (my $mapping = $self->{sourcemap}->get_mapping($file)) {
1154 0 my ($merged_entry, $callees) = $self->_merged_entry($file, $mapping, \@diagnostics);
1155  
1156 # we only care about one of the values
1157 0 ▶ if (exists $extra_reverse_files{$file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $extra_reverse_files{$file}) 0 0 0
1158 0 $extra_reverse_files{$file} = $merged_entry->{report};
1159 }
1160 0 $format_file->($merged_entry, $ends, $code, $callees, $mapping);
1161 } else {
1162 0 my $entry = $files->{$file};
1163 0 my $mapping = [
1164 [1, $file, 1],
1165 [scalar @$code, undef, scalar @$code],
1166 ];
1167 0 my $callees = $self->_callees_by_file($entry);
1168  
1169 0 $format_file->($entry, $ends, $code, $callees, $mapping);
1170 }
1171 }
1172  
1173 # logical files (just copies the content of the report written by
1174 # the loop above
1175 0 for my $file (@second_pass) {
1176 # this can only be a mapped copy of an existing file
1177 0 my $reverse_file = $self->{sourcemap}->get_reverse_mapping($file);
1178  
1179 0 ▶ unless ($reverse_file) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($reverse_file) 0 0 0
1180 0 push @diagnostics, "Unable to find reverse file for '$file'";
1181 0 next;
1182 }
1183  
1184 0 my $target = $files->{$file}->{report};
1185 my $source = $extra_reverse_files{$reverse_file} //
1186 0 ▶ ($files->{$reverse_file} && $files->{$reverse_file}->{report});
Condition0%0/6
$extra_reverse_files{$reverse_file} // $files->{$reverse_file} && $files->{$reverse_file}{"report"}
l!l&&r!l&&!r
000
$files->{$reverse_file} and $files->{$reverse_file}{"report"}
!ll&&!rl&&r
000
MC/DC0%0/3
$extra_reverse_files{$reverse_file} // $files->{$reverse_file} && $files->{$reverse_file}{"report"}
$extra_reverse_files{$reverse_file} $files->{$reverse_file} $files->{$reverse_file}{"report"}
Truth table0%0/4
A // B and C
A= $extra_reverse_files{$reverse_file}B= $files->{$reverse_file}C= $files->{$reverse_file}{"report"}
ABCresult
1XX1
0111
00X0
0100
1187 0 ▶ unless ($source) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($source) 0 0 0
1188 0 push @diagnostics, "Unable to find source for '$file' ($reverse_file)";
1189 0 next;
1190 }
1191 0 ▶ next if $source eq $target;
Branch: 1 branch
BranchTrueFalseTotal
if $source eq $target 0 0 0
1192  
1193 # TODO use symlink/hardlinks where available
1194 0 ▶ $source .= '.gz', $target .= '.gz' if $compress;
Branch: 1 branch
BranchTrueFalseTotal
if $compress 0 0 0
1195 0 File::Copy::copy(
1196 File::Spec::Functions::catfile($directory, $source),
1197 File::Spec::Functions::catfile($directory, $target));
1198 }
1199  
1200 # format flame graph
1201 0 my $flamegraphs;
1202 0 ▶ if ($self->{flamegraph} && %{$self->{aggregate}{flames}}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"flamegraph"} and %{$self->{"aggregate"}{"flames"};}) 0 0 0
Condition0%0/3
$self->{"flamegraph"} and %{$self->{"aggregate"}{"flames"};}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->{"flamegraph"} and %{$self->{"aggregate"}{"flames"};}
$self->{"flamegraph"} %{$self->{"aggregate"}{"flames"};}
Truth table0%0/3
A and B
A= $self->{"flamegraph"}B= %{$self->{"aggregate"}{"flames"};}
ABresult
0X0
100
111
1203 0 my %attributes;
1204  
1205 0 for my $sub (values %{$self->{aggregate}{subs}}) {
1206 $attributes{$sub->{uq_name}} = {
1207 href => $sub_link->($sub),
1208 0 function => $sub_name->($sub->{name}),
1209 };
1210 }
1211 0 $flamegraphs = $self->start_flamegraphs(\%attributes, $directory, $compress);
1212 }
1213  
1214 # format subs page
1215 0 my %subs_data = (
1216 include => $include,
1217 date => $date,
1218 subs => \@subs,
1219 sub_link => $sub_link,
1220 sub_name => $sub_name,
1221 format_total_ratio => $format_total_samples,
1222 );
1223  
1224 0 $self->_write_template($TEMPLATES{subs}, \%subs_data,
1225 $directory, 'subs.html', $compress);
1226  
1227 # format files page
1228 0 my %files_data = (
1229 include => $include,
1230 date => $date,
1231 files => \@files,
1232 file_name => $file_name,
1233 format_total_ratio => $format_total_samples,
1234 );
1235  
1236 0 $self->_write_template($TEMPLATES{files}, \%files_data,
1237 $directory, 'files.html', $compress);
1238  
1239 # format index page
1240 my %main_data = (
1241 include => $include,
1242 date => $date,
1243 files => \@files,
1244 subs => \@subs,
1245 !$flamegraphs ? () : (
1246 clickable_flamegraph=> $flamegraphs->{clickable}->flamegraph_base,
1247 zoomable_flamegraph => $flamegraphs->{zoomable}->flamegraph_base,
1248 0 ▶ ),
Branch: 1 branch
BranchTrueFalseTotal
!$flamegraphs ? : 0 0 0
1249 sub_link => $sub_link,
1250 sub_name => $sub_name,
1251 file_name => $file_name,
1252 format_total_ratio => $format_total_samples,
1253 );
1254  
1255 0 $self->_write_template($TEMPLATES{index}, \%main_data,
1256 $directory, 'index.html', $compress);
1257  
1258 # copy CSS/JS
1259 0 File::Copy::copy(
1260 File::ShareDir::dist_file('Devel-StatProfiler', 'statprofiler.css'),
1261 File::Spec::Functions::catfile($directory, 'statprofiler.css'));
1262 0 File::Copy::copy(
1263 File::ShareDir::dist_file('Devel-StatProfiler', 'sorttable.js'),
1264 File::Spec::Functions::catfile($directory, 'sorttable.js'));
1265  
1266 0 ▶ $self->complete_flamegraphs($flamegraphs) if $flamegraphs;
Branch: 1 branch
BranchTrueFalseTotal
if $flamegraphs 0 0 0
1267  
1268 0 return \@diagnostics;
1269 }
1270  
1271 24 1;
1272  
1273 __END__
« blib/lib/auto/share/dist/Devel-StatProfiler/flamegraph.pl ↑ Summary blib/lib/Devel/StatProfiler.pm »