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

filter: Statementstmt 60.7% 17 / 28 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 2 totaltotal 51.2% 21 / 41 CC 3 SCAR 12.0
CC
3
Cov
53%
fib
6.0
main
6.0
__ANON__
2.0
CRAP 3.3
« blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsMoose.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/spectralnorm.pm »
1 package Benchmark::Perl::Formance::Plugin::FibMoose;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - FibMoose - Stress recursion and method calls (Moose)
4  
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 1 our $VERSION = "0.002";
11  
12 #############################################################
13 # #
14 # Benchmark Code ahead - Don't touch without strong reason! #
15 # #
16 #############################################################
17  
18 1 our $goal;
19 1 our $count;
20  
21 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
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} ? 20 : 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__
« blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsMoose.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/spectralnorm.pm »