| 1 | package Bencher::Formatter::ScaleTime; | ||||||||||||||||||||
| 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=12 SCAR=50.5
Pod
undocumented
| |||||||||||||||||||||
| 22 | 0 | my ($self, $envres) = @_; | |||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | 0 | ▶ | return unless @{$envres->[2]}; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | # pick an appropriate time unit & format the time | ||||||||||||||||||||
| 27 | 0 | my ($min, $max) = minmax(map {$_->{time}} @{$envres->[2]}); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | # workaround for bug RT#113117 (max sometimes undef) | ||||||||||||||||||||
| 30 | 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
| |||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | 0 | my $unit = ""; | |||||||||||||||||||
| 33 | 0 | my $factor = 1; | |||||||||||||||||||
| 34 | 0 | ▶ | if ($max <= 1.5e-6) { | ||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||
| 35 | 0 | $unit = "ns"; | |||||||||||||||||||
| 36 | 0 | $factor = 1e9; | |||||||||||||||||||
| 37 | } elsif ($max <= 1.5e-3) { | ||||||||||||||||||||
| 38 | 0 | $unit = "\x{03bc}s"; # XXX enable utf | |||||||||||||||||||
| 39 | 0 | $factor = 1e6; | |||||||||||||||||||
| 40 | } elsif ($max <= 1.5) { | ||||||||||||||||||||
| 41 | 0 | $unit = "ms"; | |||||||||||||||||||
| 42 | 0 | $factor = 1e3; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 0 | $envres->[3]{'func.time_factor'} = $factor; | |||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | 0 | ▶ | if ($unit) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 48 | 0 | for my $rit (@{$envres->[2]}) { | |||||||||||||||||||
| 49 | 0 | $rit->{time} *= $factor; | |||||||||||||||||||
| 50 | 0 | ▶ | if (exists $rit->{mod_overhead_time}) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 51 | 0 | $rit->{mod_overhead_time} *= $factor; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | |||||||||||||||||||||
| 55 | 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"}
| |||||||||||||||||||||
| 56 | 0 | my $fus = $envres->[3]{'table.field_units'}; | |||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | 0 | my $i = -1; | |||||||||||||||||||
| 59 | 0 | for my $f (@{$envres->[3]{'table.fields'}}) { | |||||||||||||||||||
| 60 | 0 | $i++; | |||||||||||||||||||
| 61 | 0 | ▶ | if ($f =~ /\A(time|mod_overhead_time)\z/) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 62 | 0 | $fus->[$i] = $unit; | |||||||||||||||||||
| 63 | } | ||||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | } | ||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | 1 | 1; | |||||||||||||||||||
| 69 | # ABSTRACT: Scale time to make it convenient | ||||||||||||||||||||
| 70 | |||||||||||||||||||||
| 71 | __END__ | ||||||||||||||||||||