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

filter: Statementstmt 97.3% 37 / 38 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 86.2% 50 / 58 CC 5 SCAR 7.5
CC
5
Cov
89%
main
4.1
allocate
2.0
BEGIN
1.0
CRAP 2.1
« blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/binarytrees.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/nbody.pm »
1 package Benchmark::Perl::Formance::Plugin::Mem;
2 2 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - Mem - Stress memory operations
4  
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 our $VERSION = "0.003";
9  
10 #############################################################
11 # #
12 # Benchmark Code ahead - Don't touch without strong reason! #
13 # #
14 #############################################################
15  
16 2 our $goal;
17 2 our $count;
18  
19 2 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 2 my @stuff;
22  
23 sub allocate
24 1 ▶{
Subroutine allocate: called CC=2 SCAR=7.0
Pod undocumented
25 1 my ($options, $goal, $count) = @_;
26  
27 1 ▶ my $mygoal = ($options->{fastmode} ? 10 : 1) * $goal;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 1 0 1
28 5 ▶ my $t = timeit $count, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
29 5 my @stuff1;
30 5 $#stuff1 = $mygoal;
31 1 };
32 return {
33 1 Benchmark => $t,
34 goal => $mygoal,
35 count => $count,
36 };
37 }
38  
39 sub copy
40 1 ▶{
Subroutine copy: called CC=1 SCAR=0.0
Pod undocumented
41 1 my ($options, $goal, $count) = @_;
42  
43 5 ▶ my $t = timeit $count, sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
44 5 my @copy = @stuff;
45 1 };
46 return {
47 1 Benchmark => $t,
48 goal => $goal,
49 count => $count,
50 };
51 }
52  
53 sub main
54 1 ▶{
Subroutine main: called CC=4 SCAR=14.2
Pod undocumented
55 1 my ($options) = @_;
56  
57 1 ▶ $goal = $options->{fastmode} ? 2_000_000 : 15_000_000;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 1 0 1
58 1 ▶ $count = $options->{fastmode} ? 5 : 20;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 1 0 1
59  
60 1 $#stuff = $goal;
61 1 my $size;
62 1 ▶ eval qq{use Devel::Size 'total_size'};
Subroutine BEGIN: called CC=1 SCAR=0.0
63 1 ▶ if ($@) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) { } 0 1 1
64 0 $size = "error-no-Devel-Size-available";
65 } else {
66 1 $size = total_size(\@stuff);
67 }
68  
69 return {
70 1 total_size_bytes => $size,
71 copy => copy ($options, $goal, $count),
72 allocate => allocate ($options, $goal, $count),
73 };
74 }
75  
76 2 1;
77  
78 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/binarytrees.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/nbody.pm »