BenchmarkRole.pm

filter: Statementstmt 41.1% 21 / 51 Branchbran 0.0% 0 / 8 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 2 totaltotal 34.1% 27 / 79 CC 8 SCAR 27.6
CC
8
Cov
32%
benchmark
30.0
dump_benchmarks
20.0
BEGIN
1.0
CRAP 15.7
« EC2.pm ↑ Summary Route53.pm »
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}
l!l&&r!l&&!r
000
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}
ABresult
1X1
011
000
29 0 ▶ next if $_ eq 'elapsed_time';
Branch: 1 branch
BranchTrueFalseTotal
if $_ eq "elapsed_time" 0 0 0
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
BranchTrueFalseTotal
unless ($name and $self->get_benchmark) 0 0 0
Condition0%0/3
$name and $self->get_benchmark
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if exists $t->{$name} 0 0 0
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
BranchTrueFalseTotal
if (@benchmark_parts) 0 0 0
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;
« EC2.pm ↑ Summary Route53.pm »