PerlStone2015/fiboo.pm

filter: Statementstmt 53.8% 14 / 26 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 42.8% 3 / 7 Podpod 0.0% 0 / 3 totaltotal 42.5% 17 / 40 CC 3 SCAR 12.4
CC
3
Cov
47%
fib
6.0
main
6.0
new
2.0
CRAP 3.4
« PerlStone2015/fib.pm ↑ Summary
1 package Benchmark::Perl::Formance::Plugin::PerlStone2015::fiboo;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark - Fibonacci - Stress recursion and function calls (plain OO)
4 1 $Benchmark::Perl::Formance::Plugin::PerlStone2015::fiboo::VERSION = '0.002';
5 # Fibonacci numbers
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 #############################################################
11 # #
12 # Benchmark Code ahead - Don't touch without strong reason! #
13 # #
14 #############################################################
15  
16 1 our $goal;
17 1 our $count;
18  
19 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
22 0 bless {}, shift;
23 }
24  
25 sub fib
26 0 ▶{
Subroutine fib: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my $self = shift;
28 0 my $n = shift;
29  
30 0 ▶ $n < 2
Branch: 1 branch
BranchTrueFalseTotal
$n < 2 ? : 0 0 0
31 ? 1
32 : $self->fib($n-1) + $self->fib($n-2);
33 }
34  
35 sub main
36 0 ▶{
Subroutine main: not called CC=2 SCAR=17.9
Pod undocumented
37 0 my ($options) = @_;
38  
39 # ensure same values over all fib* plugins!
40 0 ▶ $goal = $options->{fastmode} ? 28 : 35;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
41 0 $count = 5;
42  
43 0 my $result;
44 0 my $fib = __PACKAGE__->new;
45 0 ▶ my $t = timeit $count, sub { $result = $fib->fib($goal) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
46 return {
47 0 Benchmark => $t,
48 result => $result,
49 goal => $goal,
50 };
51 }
52  
53 1 1;
54  
55 __END__
« PerlStone2015/fib.pm ↑ Summary