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