| 1 | package Bencher::Formatter::ScaleSize; | ||||||||||||||||||||||
| 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 List::MoreUtils qw(minmax); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 11 | 1 | ▶ | use POSIX (); | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 12 | |||||||||||||||||||||||
| 13 | 1 | ▶ | use Role::Tiny::With; | ||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||
| 14 | 1 | with 'Bencher::Role::ResultMunger'; | |||||||||||||||||||||
| 15 | |||||||||||||||||||||||
| 16 | 1 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |||||||||||||||||||||
| 17 | 1 | our $DATE = '2023-07-08'; # DATE | |||||||||||||||||||||
| 18 | 1 | our $DIST = 'Bencher-Backend'; # DIST | |||||||||||||||||||||
| 19 | 1 | our $VERSION = '1.063'; # VERSION | |||||||||||||||||||||
| 20 | |||||||||||||||||||||||
| 21 | 0 | ▶ | sub munge_result { | ||||||||||||||||||||
|
Subroutine
munge_result: not called CC=14 SCAR=53.5
Pod
undocumented
| |||||||||||||||||||||||
| 22 | 0 | my ($self, $envres) = @_; | |||||||||||||||||||||
| 23 | |||||||||||||||||||||||
| 24 | 0 | ▶ | return unless @{$envres->[2]}; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 25 | |||||||||||||||||||||||
| 26 | 0 | my @cols = grep {/^(result|proc_\w+|proc|arg\_\w+)_size$/} keys %{ $envres->[2][0] }; | |||||||||||||||||||||
| 27 | 0 | ▶ | return unless @cols; | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 28 | |||||||||||||||||||||||
| 29 | COL: | ||||||||||||||||||||||
| 30 | 0 | for my $col (@cols) { | |||||||||||||||||||||
| 31 | # pick an appropriate time unit & format the time | ||||||||||||||||||||||
| 32 | 0 | my ($min, $max) = minmax(map {$_->{$col}} @{$envres->[2]}); | |||||||||||||||||||||
| 33 | |||||||||||||||||||||||
| 34 | # workaround for bug RT#113117 (max sometimes undef) | ||||||||||||||||||||||
| 35 | 0 | ▶ | $max //= $min; | ||||||||||||||||||||
|
Condition0%0/3
$max //= $min
MC/DC0%0/2
$max //= $min
$max
$min
Truth table0%0/3
A //= B
A= $maxB= $min
| |||||||||||||||||||||||
| 36 | |||||||||||||||||||||||
| 37 | 0 | my ($unit, $factor); | |||||||||||||||||||||
| 38 | 0 | ▶ | if ($max >= 1.1*2**40) { | ||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||
| 39 | 0 | $unit = "TB"; | |||||||||||||||||||||
| 40 | 0 | $factor = 2**-40; | |||||||||||||||||||||
| 41 | } elsif ($max >= 1.1*2**30) { | ||||||||||||||||||||||
| 42 | 0 | $unit = "GB"; | |||||||||||||||||||||
| 43 | 0 | $factor = 2**-30; | |||||||||||||||||||||
| 44 | } elsif ($max >= 1.1*2**20) { | ||||||||||||||||||||||
| 45 | 0 | $unit = "MB"; | |||||||||||||||||||||
| 46 | 0 | $factor = 2**-20; | |||||||||||||||||||||
| 47 | } elsif ($max >= 1.1*2**10) { | ||||||||||||||||||||||
| 48 | 0 | $unit = "kB"; | |||||||||||||||||||||
| 49 | 0 | $factor = 2**-10; | |||||||||||||||||||||
| 50 | } else { | ||||||||||||||||||||||
| 51 | 0 | $unit = "b"; | |||||||||||||||||||||
| 52 | 0 | $factor = 1; | |||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||
| 54 | |||||||||||||||||||||||
| 55 | 0 | ▶ | if ($unit) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 56 | 0 | for my $rit (@{$envres->[2]}) { | |||||||||||||||||||||
| 57 | 0 | $rit->{$col} *= $factor; | |||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||
| 59 | |||||||||||||||||||||||
| 60 | 0 | ▶ | $envres->[3]{'table.field_units'} //= []; | ||||||||||||||||||||
|
Condition0%0/2
$envres->[3]{"table.field_units"} //= []
MC/DC0%0/1
$envres->[3]{"table.field_units"} //= []
$envres->[3]{"table.field_units"}
Truth table0%0/2
A
A= $envres->[3]{"table.field_units"}
| |||||||||||||||||||||||
| 61 | 0 | my $fus = $envres->[3]{'table.field_units'}; | |||||||||||||||||||||
| 62 | |||||||||||||||||||||||
| 63 | 0 | my $i = -1; | |||||||||||||||||||||
| 64 | 0 | for my $f (@{$envres->[3]{'table.fields'}}) { | |||||||||||||||||||||
| 65 | 0 | $i++; | |||||||||||||||||||||
| 66 | 0 | ▶ | if ($f eq $col) { | ||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||
| 67 | 0 | $fus->[$i] = $unit; | |||||||||||||||||||||
| 68 | 0 | last; | |||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||
| 71 | } # if unit | ||||||||||||||||||||||
| 72 | } # for each column | ||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||
| 74 | |||||||||||||||||||||||
| 75 | 1 | 1; | |||||||||||||||||||||
| 76 | # ABSTRACT: Scale size fields to make it convenient | ||||||||||||||||||||||
| 77 | |||||||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||||||