| 1 | package App::BenchmarkRole; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use List::Util qw(sum); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use Role::Tiny; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Time::HiRes qw(gettimeofday tv_interval); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use parent qw(Class::Accessor::Fast); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 1 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||
| 15 | 1 | __PACKAGE__->mk_accessors(qw(benchmark)); | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | ######################################################################## | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | sub dump_benchmarks { | ||||||||||||||||||||||||||
|
Subroutine
dump_benchmarks: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 19 | ######################################################################## | ||||||||||||||||||||||||||||
| 20 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 0 | my $benchmark = $self->get_benchmark(); | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 0 | my %benchmarks = %{ $benchmark->{t} }; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 0 | my @sorted_benchmarks; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 0 | ▶ | foreach ( sort { $a cmp $b || $benchmarks{$a} <=> $benchmarks{$b} } keys %benchmarks ) { | ||||||||||||||||||||||||||
|
Condition0%0/3
$a cmp $b || $benchmarks{$a} <=> $benchmarks{$b}
MC/DC0%0/2
$a cmp $b || $benchmarks{$a} <=> $benchmarks{$b}
$a cmp $b
$benchmarks{$a} <=> $benchmarks{$b}
Truth table0%0/3
A || B
A= $a cmp $bB= $benchmarks{$a} <=> $benchmarks{$b}
| |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | next if $_ eq 'elapsed_time'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 0 | push @sorted_benchmarks, $_, $benchmarks{$_}; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 0 | return @sorted_benchmarks; | |||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | ######################################################################## | ||||||||||||||||||||||||||||
| 38 | 0 | ▶ | sub benchmark { | ||||||||||||||||||||||||||
|
Subroutine
benchmark: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 39 | ######################################################################## | ||||||||||||||||||||||||||||
| 40 | 0 | my ( $self, $name ) = @_; | |||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | if ( !$name || !$self->get_benchmark ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$name and $self->get_benchmark
MC/DC0%0/2
$name and $self->get_benchmark
$name
$self->get_benchmark
Truth table0%0/3
A and B
A= $nameB= $self->get_benchmark
| |||||||||||||||||||||||||||||
| 43 | 0 | my $t0 = [gettimeofday]; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | $self->set_benchmark( | |||||||||||||||||||||||||||
| 46 | { t0 => $t0, | ||||||||||||||||||||||||||||
| 47 | t1 => $t0, | ||||||||||||||||||||||||||||
| 48 | t => {}, | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 0 | return; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $benchmark = $self->get_benchmark; | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | my ( $t, $t0, $t1 ) = @{$benchmark}{qw(t t0 t1)}; | |||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | return $t->{$name} | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if exists $t->{$name}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 0 | $t->{elapsed_time} = tv_interval( $t0, [gettimeofday] ); | |||||||||||||||||||||||||||
| 63 | 0 | my $prefix = $name . q{:}; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 0 | my @benchmark_parts = map { $t->{$_} } grep {/^$prefix/xsm} keys %{$t}; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||
| 67 | 0 | $t->{$name} += tv_interval( $t1, [gettimeofday] ); | |||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | 0 | ▶ | if (@benchmark_parts) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | 0 | $t->{$name} += sum @benchmark_parts; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | $benchmark->{t1} = [gettimeofday]; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | 0 | return $t->{$name}; | |||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 1 | 1; | |||||||||||||||||||||||||||