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