PerlStone2015/01overview.pm

filter: Statementstmt 38.3% 23 / 60 Branchbran 0.0% 0 / 20 Conditioncond 0.0% 0 / 16 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 38.4% 5 / 13 Podpod 0.0% 0 / 4 totaltotal 23.5% 28 / 119 CC 17 SCAR 30.6
CC
17
Cov
24%
opmix1_worker
42.0
opmix2_worker
42.0
opmix1
12.0
CRAP 21.3
« PerlStone2015/fasta.pm ↑ Summary PerlStone2015/revcomp.pm »
1 package Benchmark::Perl::Formance::Plugin::PerlStone2015::01overview;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark - perl 01 - overview
4 1 $Benchmark::Perl::Formance::Plugin::PerlStone2015::01overview::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 1 ▶no warnings 'recursion';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 #############################################################
10 # #
11 # Benchmark Code ahead - Don't touch without strong reason! #
12 # #
13 #############################################################
14  
15 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 my @a;
19 my %h;
20 1 my $s;
21  
22 # ----- operator mix -----
23  
24 sub opmix1_worker
25 0 ▶{
Subroutine opmix1_worker: not called CC=6 SCAR=37.4
Pod undocumented
26 0 my $n = shift;
27  
28 0 ▶ $n % 2 and bless{1..4} and $h{$n} and $a[$n] and $s =~ s/$/../;
Branch: 1 branch
BranchTrueFalseTotal
$n % 2 and bless {1..4} and $h{$n} and $a[$n] and $s =~ s/$/../ 0 0 0
Condition0%0/8
$n % 2 and bless {1..4} and $h{$n} and $a[$n]
!ll&&!rl&&r
000
$n % 2 and bless {1..4} and $h{$n}
!ll&&!rl&&r
000
$n % 2 and bless {1..4}
!ll
00
MC/DC0%0/3
$n % 2 and bless {1..4} and $h{$n} and $a[$n]
$n % 2 $h{$n} $a[$n]
Truth table0%0/4
A and B and C
A= $n % 2B= $h{$n}C= $a[$n]
ABCresult
0XX0
10X0
1100
1111
29 0 ▶ $n<2 and return $n;
Branch: 1 branch
BranchTrueFalseTotal
$n < 2 and return $n 0 0 0
30 0 opmix1_worker($n-1) + opmix1_worker($n-2);
31 }
32  
33 sub opmix1
34 0 ▶{
Subroutine opmix1: not called CC=3 SCAR=24.8
Pod undocumented
35 0 my ($options) = @_;
36  
37 0 ▶ my $goal = $options->{fastmode} ? 25 : 27;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
38 0 ▶ my $count = $options->{fastmode} ? 1 : 5;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
39  
40 0 ▶ my $t = timeit $count, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
41 0 @a = (0..31);
42 0 %h = (1..100);
43 0 $s = '0123456789';
44 0 opmix1_worker($goal)
45 0 };
46  
47 return {
48 0 Benchmark => $t,
49 goal => $goal,
50 count => $count,
51 };
52 }
53  
54 # ----- operator mix with method calls -----
55 {
56 package Benchmark::Perl::Formance::Plugin::PerlStone2015::01overview::opmix2;
57 1 our $AUTHORITY = 'cpan:SCHWIGON';
58 1 $Benchmark::Perl::Formance::Plugin::PerlStone2015::01overview::opmix2::VERSION = '0.002';
59 0 ▶sub new { my $c = shift; bless { @_ }, $c }
Subroutine new: not called CC=1 SCAR=6.9
60  
61 sub opmix2_worker
62 0 ▶ {
Subroutine opmix2_worker: not called CC=6 SCAR=37.4
63 0 my ($self, $n) = (shift, shift);
64  
65 0 ▶ $n % 2 and bless{1..4} and $h{$n} and $a[$n] and $s =~ s/$/../;
Branch: 1 branch
BranchTrueFalseTotal
$n % 2 and bless {1..4} and $h{$n} and $a[$n] and $s =~ s/$/../ 0 0 0
Condition0%0/8
$n % 2 and bless {1..4} and $h{$n} and $a[$n]
!ll&&!rl&&r
000
$n % 2 and bless {1..4} and $h{$n}
!ll&&!rl&&r
000
$n % 2 and bless {1..4}
!ll
00
MC/DC0%0/3
$n % 2 and bless {1..4} and $h{$n} and $a[$n]
$n % 2 $h{$n} $a[$n]
Truth table0%0/4
A and B and C
A= $n % 2B= $h{$n}C= $a[$n]
ABCresult
0XX0
10X0
1100
1111
66 0 ▶ $n<2 and return $n;
Branch: 1 branch
BranchTrueFalseTotal
$n < 2 and return $n 0 0 0
67 0 $self->opmix2_worker($n-1) + $self->opmix2_worker($n-2);
68 }
69 }
70  
71 sub opmix2
72 1 ▶{
Subroutine opmix2: not called CC=3 SCAR=23.3
Pod undocumented
73 0 my ($options) = @_;
74  
75 0 ▶ my $goal = $options->{fastmode} ? 25 : 27;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
76 0 ▶ my $count = $options->{fastmode} ? 1 : 5;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
77  
78 0 my $worker = Benchmark::Perl::Formance::Plugin::PerlStone2015::01overview::opmix2->new;
79 0 ▶ my $t = timeit $count, sub {
Subroutine __ANON__: not called CC=1 SCAR=6.9
80 0 @a = (0..31);
81 0 %h = (1..100);
82 0 $s = '0123456789';
83 0 $worker->opmix2_worker($goal)
84 0 };
85  
86 return {
87 0 Benchmark => $t,
88 goal => $goal,
89 count => $count,
90 };
91 }
92  
93 sub main
94 0 ▶{
Subroutine main: not called CC=3 SCAR=24.8
Pod undocumented
95 0 my ($options) = @_;
96  
97 0 my $results;
98 0 eval {
99 0 $results = {
100 opmix1 => opmix1($options),
101 opmix2 => opmix2($options),
102 };
103 };
104  
105 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
106 0 ▶ warn $@ if $options->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} 0 0 0
107 0 $results = { failed => $@ };
108 }
109  
110 0 return $results;
111 }
112  
113 1 1;
114  
115 __END__
« PerlStone2015/fasta.pm ↑ Summary PerlStone2015/revcomp.pm »