Bencher/Formatter/AddComparisonFields.pm

filter: Statementstmt 58.3% 21 / 36 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 62.5% 5 / 8 Podpod 0.0% 0 / 1 totaltotal 42.6% 26 / 61 CC 9 SCAR 32.7
CC
9
Cov
44%
munge_result
56.0
__ANON__
6.0
__ANON__
6.0
CRAP 26.3
« Bencher/Formatter/Sort.pm ↑ Summary Bencher/Formatter/DeleteConstantFields.pm »
1 package Bencher::Formatter::AddComparisonFields;
2  
3 1 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use parent qw(Bencher::Formatter);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 with 'Bencher::Role::FieldMunger';
11 1 with 'Bencher::Role::ResultMunger';
12  
13 1 our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY
14 1 our $DATE = '2023-07-08'; # DATE
15 1 our $DIST = 'Bencher-Backend'; # DIST
16 1 our $VERSION = '1.063'; # VERSION
17  
18 0 ▶sub munge_result {
Subroutine munge_result: not called CC=7 SCAR=40.3
Pod undocumented
19 0 my ($self, $envres) = @_;
20  
21 0 my $slowest_time;
22 my $fastest_time;
23 0 for my $rit (@{ $envres->[2] }) {
24 $slowest_time = $rit->{time}
25 0 ▶ if !defined($slowest_time) || $slowest_time < $rit->{time};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $slowest_time or $slowest_time < $rit->{"time"} 0 0 0
Condition0%0/3
not defined $slowest_time or $slowest_time < $rit->{"time"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $slowest_time or $slowest_time < $rit->{"time"}
not defined $slowest_time $slowest_time < $rit->{"time"}
Truth table0%0/3
not(A) or B
A= not defined $slowest_timeB= $slowest_time < $rit->{"time"}
ABresult
1X1
011
000
26 $fastest_time = $rit->{time}
27 0 ▶ if !defined($fastest_time) || $fastest_time > $rit->{time};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $fastest_time or $fastest_time > $rit->{"time"} 0 0 0
Condition0%0/3
not defined $fastest_time or $fastest_time > $rit->{"time"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $fastest_time or $fastest_time > $rit->{"time"}
not defined $fastest_time $fastest_time > $rit->{"time"}
Truth table0%0/3
not(A) or B
A= not defined $fastest_timeB= $fastest_time > $rit->{"time"}
ABresult
1X1
011
000
28 }
29  
30 0 ▶ return unless defined $slowest_time;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $slowest_time 0 0 0
31  
32 $self->add_field(
33 $envres,
34 'pct_faster_vs_slowest',
35 {after=>'time', align=>'number', format=>'percent'},
36 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
37 0 for my $rit (@{$envres->[2]}) {
38 $rit->{pct_faster_vs_slowest} =
39 0 ($slowest_time - $rit->{time}) / $rit->{time};;
40 }
41 }
42 0 );
43 $self->add_field(
44 $envres,
45 'pct_slower_vs_fastest',
46 {after=>'pct_faster_vs_slowest', align=>'number', format=>'percent'},
47 0 ▶ sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
48 0 for my $rit (@{$envres->[2]}) {
49 $rit->{pct_slower_vs_fastest} =
50 0 ($rit->{time} - $fastest_time) / $fastest_time;
51 }
52 }
53 0 );
54 }
55  
56 1 1;
57 # ABSTRACT: Add vs_slowest field
58  
59 __END__
« Bencher/Formatter/Sort.pm ↑ Summary Bencher/Formatter/DeleteConstantFields.pm »