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

filter: Statementstmt 33.3% 1 / 3 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 1 / 1 Podpod n/a totaltotal 50.0% 2 / 4 CC 1 SCAR 2.6
CC
1
Cov
33%
BEGIN
1.3
CRAP 1.3
« blib/lib/Benchmark/Perl/Formance/Plugin/MatrixReal.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/pidigits.pm »
1 package Benchmark::Perl::Formance::Plugin::AccessorsMouse;
2 our $AUTHORITY = 'cpan:SCHWIGON';
3 # ABSTRACT: benchmark plugin - Compare OO'ish accessors
4  
5 0 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=2.6
6  
7 use strict;
8 use warnings;
9  
10 our $VERSION = "0.001";
11  
12 #############################################################
13 # #
14 # Benchmark Code ahead - Don't touch without strong reason! #
15 # #
16 #############################################################
17  
18 our $goal;
19 our $count;
20  
21 use Benchmark ':hireswallclock';
22  
23 has 'zomtec' => (is => 'rw', default => 42);
24  
25 sub main
26 {
27 my ($options) = @_;
28  
29 # ensure same values over all Accessors* plugins!
30 $goal = $options->{fastmode} ? 100_000 : 2_000_000;
31 $count = 5;
32  
33 my $result;
34 my $obj = __PACKAGE__->new;
35 my $t_get = timeit $count, sub { $result = $obj->zomtec() for 1..$goal };
36 my $t_set = timeit $count, sub { $result = $obj->zomtec(23) for 1..$goal };
37 return {
38 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;
52  
53 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/MatrixReal.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/Shootout/pidigits.pm »