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

filter: Statementstmt 50.0% 14 / 28 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 37.5% 3 / 8 Podpod 0.0% 0 / 3 totaltotal 39.5% 17 / 43 CC 5 SCAR 14.9
CC
5
Cov
44%
zomtec
6.0
main
6.0
__ANON__
6.0
CRAP 4.4
« blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsArray.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Prime.pm »
1 package Benchmark::Perl::Formance::Plugin::AccessorsHash;
2 1 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - Compare OO'ish accessors
4  
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 1 our $VERSION = "0.001";
9  
10 #############################################################
11 # #
12 # Benchmark Code ahead - Don't touch without strong reason! #
13 # #
14 #############################################################
15  
16 1 our $goal;
17 1 our $count;
18  
19 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 0 ▶sub new {
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
22 0 bless { zomtec => 42 }, shift;
23 }
24  
25 sub zomtec
26 0 ▶{
Subroutine zomtec: not called CC=2 SCAR=17.9
Pod undocumented
27 0 my $self = shift;
28  
29 0 ▶ $self->{zomtec} = $_[0] if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
30 0 return $self->{zomtec};
31 }
32  
33 sub main
34 0 ▶{
Subroutine main: not called CC=2 SCAR=17.9
Pod undocumented
35 0 my ($options) = @_;
36  
37 # ensure same values over all Accessors* plugins!
38 0 ▶ $goal = $options->{fastmode} ? 100_000 : 2_000_000;
Branch: 1 branch
BranchTrueFalseTotal
$options->{'fastmode'} ? : 0 0 0
39 0 $count = 5;
40  
41 0 my $result;
42 0 my $obj = __PACKAGE__->new;
43 0 ▶ my $t_get = timeit $count, sub { $result = $obj->zomtec() for 1..$goal };
Subroutine __ANON__: not called CC=2 SCAR=17.9
44 0 ▶ my $t_set = timeit $count, sub { $result = $obj->zomtec(23) for 1..$goal };
Subroutine __ANON__: not called CC=2 SCAR=17.9
45 return {
46 0 get => {
47 Benchmark => $t_get,
48 result => $result,
49 goal => $goal,
50 },
51 set => {
52 Benchmark => $t_set,
53 result => $result,
54 goal => $goal,
55 },
56 };
57 }
58  
59 1 1;
60  
61 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsArray.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Prime.pm »