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

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« blib/lib/Benchmark/Perl/Formance/Plugin/ThreadsShared.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsObjectTinyRW.pm »
1 package Benchmark::Perl::Formance::Plugin::AccessorsClassMethodMaker;
2 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 our $VERSION = "0.001";
9  
10 #############################################################
11 # #
12 # Benchmark Code ahead - Don't touch without strong reason! #
13 # #
14 #############################################################
15  
16 our $goal;
17 our $count;
18  
19 1 ▶use Benchmark ':hireswallclock';
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 use Class::MethodMaker
22 0 ▶ [ scalar => 'zomtec',
Subroutine BEGIN: called CC=1 SCAR=2.6
23 new => [qw/ new /],
24 0 ];
25  
26 sub main
27 {
28 my ($options) = @_;
29  
30 # ensure same values over all Accessors* plugins!
31 $goal = $options->{fastmode} ? 100_000 : 2_000_000;
32 $count = 5;
33  
34 my $result;
35 my $obj = __PACKAGE__->new;
36 my $t_get = timeit $count, sub { $result = $obj->zomtec() for 1..$goal };
37 my $t_set = timeit $count, sub { $result = $obj->zomtec(23) for 1..$goal };
38 return {
39 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;
53  
54 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/ThreadsShared.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsObjectTinyRW.pm »