PerlStone2015/fib.pm

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