NAME

Bencher::Scenario::Accessors::Get - Benchmark attribute read/get

VERSION

This document describes version 0.11 of Bencher::Scenario::Accessors::Get (from Perl distribution Bencher-Scenarios-Accessors), released on 2016-09-29.

SYNOPSIS

To run benchmark with default option:

% bencher -m Accessors::Get

To run module startup overhead benchmark:

% bencher --module-startup -m Accessors::Get

For more options (dump scenario, list/include/exclude/add participants, list/include/exclude/add datasets, etc), see bencher or run bencher --help.

BENCHMARKED MODULES

Version numbers shown below are the versions used when running the sample benchmark.

Class::Accessor 0.34

Class::Accessor::Array 0.02

Class::InsideOut 1.13

Class::Tiny 1.004

Class::XSAccessor 1.19

Class::XSAccessor::Array 1.19

Mo 0.40

Mojo::Base

Mojo::Base::XS 0.07

Moo 2.002004

Moose 2.1805

Mouse v2.4.5

Object::Simple 3.1703

Perl::Examples::Accessors::Array 0.08

Perl::Examples::Accessors::ClassAccessor 0.08

Perl::Examples::Accessors::ClassAccessorArray 0.08

Perl::Examples::Accessors::ClassInsideOut 0.08

Perl::Examples::Accessors::ClassTiny 0.08

Perl::Examples::Accessors::ClassXSAccessor 0.08

Perl::Examples::Accessors::ClassXSAccessorArray 0.08

Perl::Examples::Accessors::Hash 0.08

Perl::Examples::Accessors::Mo 0.08

Perl::Examples::Accessors::MojoBase 0.08

Perl::Examples::Accessors::MojoBaseXS 0.08

Perl::Examples::Accessors::Moo 0.08

Perl::Examples::Accessors::Moose 0.08

Perl::Examples::Accessors::Mouse 0.08

Perl::Examples::Accessors::ObjectSimple 0.08

Perl::Examples::Accessors::SimpleAccessor 0.08

Simple::Accessor 1.02

BENCHMARK PARTICIPANTS

  • Class::Tiny (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ClassTiny->new; $o->attr1(42); $o }; $o->attr1
  • Object::Simple (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ObjectSimple->new; $o->attr1(42); $o }; $o->attr1
  • Class::Accessor (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ClassAccessor->new; $o->attr1(42); $o }; $o->attr1
  • Mouse (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Mouse->new; $o->attr1(42); $o }; $o->attr1
  • Mojo::Base::XS (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::MojoBaseXS->new; $o->attr1(42); $o }; $o->attr1
  • Moose (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Moose->new; $o->attr1(42); $o }; $o->attr1
  • Class::Accessor::Array (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ClassAccessorArray->new; $o->attr1(42); $o }; $o->attr1
  • no generator (array-based) (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Array->new; $o->attr1(42); $o }; $o->attr1
  • Class::InsideOut (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ClassInsideOut->new; $o->attr1(42); $o }; $o->attr1
  • Moo (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Moo->new; $o->attr1(42); $o }; $o->attr1
  • Mo (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Mo->new; $o->attr1(42); $o }; $o->attr1
  • Class::XSAccessor::Array (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ClassXSAccessorArray->new; $o->attr1(42); $o }; $o->attr1
  • Mojo::Base (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::MojoBase->new; $o->attr1(42); $o }; $o->attr1
  • Simple::Accessor (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::SimpleAccessor->new; $o->attr1(42); $o }; $o->attr1
  • no generator (hash-based) (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Hash->new; $o->attr1(42); $o }; $o->attr1
  • Class::XSAccessor (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::ClassXSAccessor->new; $o->attr1(42); $o }; $o->attr1
  • raw hash access (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Hash->new; $o->attr1(42); $o }; $o->{attr1}
  • raw array access (perl_code)

    Code template:

    state $o = do { my $o = Perl::Examples::Accessors::Array->new; $o->attr1(42); $o }; $o->[0]

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.24.0, CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz (4 cores), OS: GNU/Linux Debian version 8.0, OS kernel: Linux version 3.16.0-4-amd64.

Benchmark with default options (bencher -m Accessors::Get):

#table1#
+----------------------------+-----------+-----------+------------+---------+---------+
| participant                | rate (/s) | time (ns) | vs_slowest |  errors | samples |
+----------------------------+-----------+-----------+------------+---------+---------+
| Class::Accessor            |   1800000 |     560   |      1     | 8.3e-10 |      20 |
| Class::InsideOut           |   2400000 |     420   |      1.3   |   1e-09 |      20 |
| Simple::Accessor           |   2500000 |     400   |      1.4   | 9.9e-10 |      22 |
| Mojo::Base                 |   4150000 |     241   |      2.31  | 3.4e-11 |      20 |
| Mo                         |   4600000 |     218   |      2.56  |   1e-10 |      20 |
| no generator (hash-based)  |   4600000 |     220   |      2.6   | 7.5e-10 |      32 |
| Object::Simple             |   4750000 |     211   |      2.64  | 1.2e-10 |      20 |
| no generator (array-based) |   5000000 |     200   |      2.8   | 4.2e-10 |      21 |
| Class::Tiny                |   5000000 |     200   |      2.8   | 2.6e-10 |      20 |
| Moose                      |   5220000 |     191   |      2.91  | 1.1e-10 |      20 |
| Class::Accessor::Array     |   5512000 |     181.4 |      3.071 | 1.2e-11 |      20 |
| Mouse                      |  10000000 |      99.7 |      5.59  | 3.5e-11 |      20 |
| Moo                        |  12000000 |      84   |      6.6   | 4.1e-10 |      21 |
| Class::XSAccessor          |  13000000 |      80   |      7     | 4.7e-10 |      20 |
| Mojo::Base::XS             |  13000000 |      77   |      7.2   | 2.7e-10 |      20 |
| Class::XSAccessor::Array   |  17000000 |      59   |      9.5   | 2.1e-10 |      20 |
| raw hash access            |  26000000 |      39   |     14     | 2.4e-10 |      20 |
| raw array access           |  28000000 |      36   |     16     | 2.6e-10 |      20 |
+----------------------------+-----------+-----------+------------+---------+---------+

DESCRIPTION

Packaging a benchmark script as a Bencher scenario makes it convenient to include/exclude/add participants/datasets (either via CLI or Perl code), send the result to a central repository, among others . See Bencher and bencher (CLI) for more details.

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Bencher-Scenarios-Accessors.

SOURCE

Source repository is at https://github.com/perlancar/perl-Bencher-Scenarios-Accessors.

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Bencher-Scenarios-Accessors

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

SEE ALSO

AUTHOR

perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by perlancar@cpan.org.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.