PerlStone2015/04control.pm

filter: Statementstmt 32.4% 12 / 37 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 33.3% 3 / 9 Podpod 0.0% 0 / 4 totaltotal 24.1% 15 / 62 CC 11 SCAR 22.8
CC
11
Cov
24%
blocks1
12.0
__ANON__
12.0
blocks2
12.0
CRAP 9.7
« PerlStone2015/fannkuch.pm ↑ Summary PerlStone2015/regex.pm »
1 package Benchmark::Perl::Formance::Plugin::PerlStone2015::04control;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark - perl 04 - control
4 1 $Benchmark::Perl::Formance::Plugin::PerlStone2015::04control::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 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 # Entering, iterating and leaving scopes
17 # http://www.nntp.perl.org/group/perl.perl5.porters/2016/01/msg233631.html
18 sub blocks1
19 0 ▶{
Subroutine blocks1: not called CC=3 SCAR=24.8
Pod undocumented
20 0 my ($options) = @_;
21  
22 0 ▶ my $goal = $options->{fastmode} ? 9_200 : 46_000;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
23 0 ▶ my $count = $options->{fastmode} ? 1 : 3;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
24  
25 0 ▶ my $t = timeit $count, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
26 0 my @a = 1..10_000;
27 0 for (1..$goal) {
28 0 $_++ for @a;
29 }
30 0 };
31  
32 return {
33 0 Benchmark => $t,
34 goal => $goal,
35 count => $count,
36 };
37 }
38  
39 # Entering, iterating and leaving scopes - with subs
40 # http://www.nntp.perl.org/group/perl.perl5.porters/2016/01/msg233631.html
41  
42 0 ▶sub inc { $_[0]++ }
Subroutine inc: not called CC=1 SCAR=6.9
Pod undocumented
43  
44 sub blocks2
45 0 ▶{
Subroutine blocks2: not called CC=3 SCAR=24.8
Pod undocumented
46 0 my ($options) = @_;
47  
48 0 ▶ my $goal = $options->{fastmode} ? 2_000 : 10_000;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
49 0 ▶ my $count = $options->{fastmode} ? 1 : 3;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
50  
51 0 ▶ my $t = timeit $count, sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
52 0 my @a = 1..10_000;
53 0 for (1..$goal) {
54 0 inc($_) for @a;
55 }
56 0 };
57  
58 return {
59 0 Benchmark => $t,
60 goal => $goal,
61 count => $count,
62 };
63 }
64  
65 sub main
66 0 ▶{
Subroutine main: not called CC=3 SCAR=24.8
Pod undocumented
67 0 my ($options) = @_;
68  
69 0 my $results;
70 0 eval {
71 0 $results = {
72 blocks1 => blocks1($options),
73 blocks2 => blocks2($options),
74 };
75 };
76  
77 0 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
78 0 ▶ warn $@ if $options->{verbose};
Branch: 1 branch
BranchTrueFalseTotal
if $options->{"verbose"} 0 0 0
79 0 $results = { failed => $@ };
80 }
81  
82 0 return $results;
83 }
84  
85 1 1;
86  
87 __END__
« PerlStone2015/fannkuch.pm ↑ Summary PerlStone2015/regex.pm »