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

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