blib/lib/Benchmarks.pm

filter: Statementstmt 96.1% 25 / 26 Branchbran 70.0% 14 / 20 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 100% 5 / 5 Podpod n/a totaltotal 83.9% 47 / 56 SCAR 25.4
CC
12
Cov
84%
import
9.6
_run_benchmark
4.2
BEGIN
1.0
CRAP 12.6
↑ Summary Build »
1 package Benchmarks;
2 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use Benchmark qw/ :hireswallclock /;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 7 our $VERSION = '0.09';
6  
7 sub import {
8 7 ▶ my ($class, $code, $count, $style, $title) = @_;
Subroutine import: called CC=9 SCAR=22.7
9  
10 7 Benchmark->export_to_level(1, $class, ':all');
11  
12 7 ▶ return unless $code;
Branch: 1 branch
BranchTrueFalseTotal
unless $code 2 5 7
13 5 ▶ return unless ref $code eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code eq "CODE" 0 5 5
14  
15 5 my ($ret, $runtime_count, $runtime_style, $runtime_title) = $code->();
16 5 ▶ $count = defined($runtime_count) ? $runtime_count
Branch: 2 branches
BranchTrueFalseTotal
defined $runtime_count ? : 0 5 5
defined $count ? : 5 0 5
17 : defined($count) ? $count
18 : -1;
19 5 ▶ $style = defined($runtime_style) ? $runtime_style
Branch: 2 branches
BranchTrueFalseTotal
defined $runtime_style ? : 0 5 5
defined $style ? : 3 2 5
20 : defined($style) ? $style
21 : 'auto';
22 5 ▶ $title = defined($runtime_title) ? $runtime_title
Branch: 2 branches
BranchTrueFalseTotal
defined $runtime_title ? : 0 5 5
defined $title ? : 1 4 5
23 : defined($title) ? $title
24 : undef;
25  
26 5 _run_benchmark($count, $ret, $style, $title);
27 }
28  
29 sub _run_benchmark {
30 5 ▶ my ($count, $ret, $style, $title) = @_;
Subroutine _run_benchmark: called CC=4 SCAR=14.3
31  
32 5 my $ref_ret = ref $ret;
33  
34 5 ▶ if ( !$ref_ret || $ref_ret eq 'CODE' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $ref_ret or $ref_ret eq 'CODE') { } 3 2 5
elsif ($ref_ret eq 'HASH') { } 2 0 2
Condition66%2/3
not $ref_ret or $ref_ret eq "CODE"
l!l&&r!l&&!r
032
MC/DC50%1/2
not $ref_ret or $ref_ret eq "CODE"
not $ref_ret $ref_ret eq "CODE"
Truth table66%2/3
not(A) or B
A= not $ref_retB= $ref_ret eq "CODE"
ABresult
1X1
011
000
35 3 Benchmark::timethis($count, $ret, $title, $style);
36 }
37 elsif ( $ref_ret eq 'HASH' ) {
38 2 Benchmark::cmpthese($count, $ret, $style);
39 }
40 else {
41 0 die "The CODE returned wrong retval.";
42 }
43 }
44  
45 7 1;
46  
47 __END__
↑ Summary Build »