blib/lib/Benchmark/Perl/Formance/Plugin/FibOOSig.pm

filter: Statementstmt 65.6% 21 / 32 Branchbran 16.6% 1 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 60.0% 6 / 10 Podpod 0.0% 0 / 3 totaltotal 54.9% 28 / 51 CC 4 SCAR 10.7
CC
4
Cov
58%
fib
6.0
main
6.0
BEGIN
2.5
CRAP 2.9
« blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/spectralnorm.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/binarytrees.pm »
1 package Benchmark::Perl::Formance::Plugin::FibOOSig;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - FibOOSig - Stress recursion and method calls (plain OO with function signatures)
4  
5 # Fibonacci numbers, using methods with signatures (Perl 5.20+)
6  
7 1 ▶BEGIN {
Subroutine BEGIN: called CC=2 SCAR=9.2
8 1 ▶ if ($] < 5.020) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] < "5.02") 0 1 1
9 0 die "Perl 5.020+ required for subs with signatures.\n";
10 }
11 }
12  
13 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 1 ▶use experimental 'signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶no warnings 'experimental::signatures';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 our $VERSION = "0.002";
19  
20 #############################################################
21 # #
22 # Benchmark Code ahead - Don't touch without strong reason! #
23 # #
24 #############################################################
25  
26 1 our $goal;
27 1 our $count;
28  
29 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
30  
31 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
32 0 bless {}, shift;
33 }
34  
35 0 ▶sub fib ($self, $n)
Subroutine fib: not called CC=2 SCAR=17.9
Pod undocumented
36 {
37 0 ▶ $n < 2
Branch: 1 branch
BranchTrueFalseTotal
$n < 2 ? : 0 0 0
38 ? 1
39 : $self->fib($n-1) + $self->fib($n-2);
40 }
41  
42 sub main
43 0 ▶{
Subroutine main: not called CC=2 SCAR=17.9
Pod undocumented
44 0 my ($options) = @_;
45  
46 # ensure same values over all Fib* plugins!
47 0 ▶ $goal = $options->{fastmode} ? 20 : 35;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
48 0 $count = 5;
49  
50 0 my $result;
51 0 my $fib = __PACKAGE__->new;
52 0 ▶ my $t = timeit $count, sub { $result = $fib->fib($goal) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
53 return {
54 0 Benchmark => $t,
55 result => $result,
56 goal => $goal,
57 };
58 }
59  
60 1 1;
61  
62 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/spectralnorm.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/binarytrees.pm »