Bencher/Formatter/Sort.pm

filter: Statementstmt 64.5% 20 / 31 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 83.3% 5 / 6 Podpod 0.0% 0 / 1 totaltotal 44.6% 25 / 56 CC 9 SCAR 40.6
CC
9
Cov
43%
munge_result
90.0
BEGIN
1.0
BEGIN
1.0
CRAP 58.2
« Bencher/Formatter/RenderAsBenchmarkPm.pm ↑ Summary Bencher/Formatter/AddComparisonFields.pm »
1 package Bencher::Formatter::Sort;
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 #use Log::Any::IfLOG '$log';
7  
8 1 ▶use parent qw(Bencher::Formatter);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 ▶use Role::Tiny::With;
Subroutine BEGIN: called CC=1 SCAR=0.0
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=9 SCAR=45.0
Pod undocumented
19 0 my ($self, $envres) = @_;
20  
21 0 ▶ $self->{by} //= ['-time'];
Condition0%0/2
$self->{"by"} //= ["-time"]
l!l
00
MC/DC0%0/1
$self->{"by"} //= ["-time"]
$self->{"by"}
Truth table0%0/2
A
A= $self->{"by"}
Aresult
11
00
22  
23 # sort by default from slowest to fastest
24 $envres->[2] = [sort {
25 0 for my $by0 (@{ $self->{by} }) {
26 0 my ($desc, $by) = $by0 =~ /^(-?)(.+)/;
27 0 ▶ return 0 unless defined($a->{$by}) && defined($b->{$by});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $Bencher::Formatter::Sort::a->{$by} and defined $Bencher::Formatter::Sort::b->{$by} 0 0 0
Condition0%0/3
defined $Bencher::Formatter::Sort::a->{$by} and defined $Bencher::Formatter::Sort::b->{$by}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $Bencher::Formatter::Sort::a->{$by} and defined $Bencher::Formatter::Sort::b->{$by}
defined $Bencher::Formatter::Sort::a->{$by} defined $Bencher::Formatter::Sort::b->{$by}
Truth table0%0/3
A and B
A= defined $Bencher::Formatter::Sort::a->{$by}B= defined $Bencher::Formatter::Sort::b->{$by}
ABresult
0X0
100
111
28 0 ▶ my $numeric = $by =~ /time|errors|samples/ ? 1:0; # XXX ad-hoc
Branch: 1 branch
BranchTrueFalseTotal
$by =~ /time|errors|samples/ ? : 0 0 0
29 my $res = ($desc ? -1:1) * ($numeric ?
30 $a->{$by} <=> $b->{$by} :
31 0 ▶ $a->{$by} cmp $b->{$by});
Branch: 2 branches
BranchTrueFalseTotal
$desc ? : 0 0 0
$numeric ? : 0 0 0
32 0 ▶ return $res if $res;
Branch: 1 branch
BranchTrueFalseTotal
if $res 0 0 0
33 }
34 0;
35 0 } @{$envres->[2]}];
36 }
37  
38 1 1;
39 # ABSTRACT: Sort rows
40  
41 __END__
« Bencher/Formatter/RenderAsBenchmarkPm.pm ↑ Summary Bencher/Formatter/AddComparisonFields.pm »