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

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/Benchmark/Perl/Formance/Plugin/FibMXDeclare.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/fannkuch.pm »
1 package Benchmark::Perl::Formance::Plugin::FibMouse;
2 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - FibMouse - Stress recursion and method calls (Mouse)
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 our $VERSION = "0.002";
11  
12 #############################################################
13 # #
14 # Benchmark Code ahead - Don't touch without strong reason! #
15 # #
16 #############################################################
17  
18 our $goal;
19 our $count;
20  
21 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
22  
23 0 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=2.6
24  
25 sub fib
26 {
27 my $self = shift;
28 my $n = shift;
29  
30 $n < 2
31 ? 1
32 : $self->fib($n-1) + $self->fib($n-2);
33 }
34  
35 sub main
36 {
37 my ($options) = @_;
38  
39 # ensure same values over all Fib* plugins!
40 $goal = $options->{fastmode} ? 20 : 35;
41 $count = 5;
42  
43 my $result;
44 my $fib = __PACKAGE__->new;
45 my $t = timeit $count, sub { $result = $fib->fib($goal) };
46 return {
47 Benchmark => $t,
48 result => $result,
49 goal => $goal,
50 };
51 }
52  
53 1;
54  
55 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/FibMXDeclare.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/fannkuch.pm »