blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsObjectTinyRW.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/AccessorsClassMethodMaker.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/FibMXDeclare.pm »
1 package Benchmark::Perl::Formance::Plugin::AccessorsObjectTinyRW;
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 0 ▶use Object::Tiny::RW "zomtec";
Subroutine BEGIN: called CC=1 SCAR=2.6
22  
23 sub main
24 {
25 my ($options) = @_;
26  
27 # ensure same values over all Accessors* plugins!
28 $goal = $options->{fastmode} ? 100_000 : 2_000_000;
29 $count = 5;
30  
31 my $result;
32 my $obj = __PACKAGE__->new;
33 my $t_get = timeit $count, sub { $result = $obj->zomtec() for 1..$goal };
34 my $t_set = timeit $count, sub { $result = $obj->zomtec(23) for 1..$goal };
35 return {
36 get => {
37 Benchmark => $t_get,
38 result => $result,
39 goal => $goal,
40 },
41 set => {
42 Benchmark => $t_set,
43 result => $result,
44 goal => $goal,
45 },
46 };
47 }
48  
49 1;
50  
51 __END__
« blib/lib/Benchmark/Perl/Formance/Plugin/AccessorsClassMethodMaker.pm ↑ Summary blib/lib/Benchmark/Perl/Formance/Plugin/FibMXDeclare.pm »