NAME
Bencher::Scenario::Accessors::Get - Benchmark attribute read/get
VERSION
This document describes version 0.151 of Bencher::Scenario::Accessors::Get (from Perl distribution Bencher-ScenarioBundle-Accessors), released on 2024-05-06.
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
.
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.
BENCHMARKED MODULES
Version numbers shown below are the versions used when running the sample benchmark.
Class::Accessor 0.51
Class::Accessor::Array 0.032
Class::Accessor::PackedString 0.001
Class::Accessor::PackedString::Set 0.001
Class::InsideOut 1.14
Class::Struct 0.68
Class::Tiny 1.008
Class::XSAccessor 1.19
Mo 0.40
Mojo::Base::XS 0.07
Moo 2.005005
Moops 0.038
Moos 0.30
Moose 2.2206
Mouse v2.5.10
Object::Pad 0.806
Object::Simple 3.19
Object::Tiny 1.09
Object::Tiny::RW 1.07
Object::Tiny::RW::XS 0.04
Object::Tiny::XS 1.01
Perl::Examples::Accessors::Array 0.132
Perl::Examples::Accessors::ClassAccessor 0.132
Perl::Examples::Accessors::ClassAccessorArray 0.132
Perl::Examples::Accessors::ClassAccessorPackedString 0.132
Perl::Examples::Accessors::ClassAccessorPackedStringSet 0.132
Perl::Examples::Accessors::ClassInsideOut 0.132
Perl::Examples::Accessors::ClassStruct 0.132
Perl::Examples::Accessors::ClassTiny 0.132
Perl::Examples::Accessors::ClassXSAccessor 0.132
Perl::Examples::Accessors::ClassXSAccessorArray 0.132
Perl::Examples::Accessors::Hash 0.132
Perl::Examples::Accessors::Mo 0.132
Perl::Examples::Accessors::MojoBase 0.132
Perl::Examples::Accessors::MojoBaseXS 0.132
Perl::Examples::Accessors::Moo 0.132
Perl::Examples::Accessors::Moops 0.132
Perl::Examples::Accessors::Moos 0.132
Perl::Examples::Accessors::Moose 0.132
Perl::Examples::Accessors::Mouse 0.132
Perl::Examples::Accessors::ObjectPad 0.132
Perl::Examples::Accessors::ObjectSimple 0.132
Perl::Examples::Accessors::ObjectTiny 0.132
Perl::Examples::Accessors::ObjectTinyRW 0.132
Perl::Examples::Accessors::ObjectTinyRWXS 0.132
Perl::Examples::Accessors::ObjectTinyXS 0.132
Perl::Examples::Accessors::SimpleAccessor 0.132
Simple::Accessor 1.13
BENCHMARK PARTICIPANTS
Class::Tiny (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassTiny->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
Mojo::Base (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::MojoBase->new; $o->attr1(42); $o }; $o->attr1
Object::Tiny::RW::XS (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectTinyRWXS->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
Moops (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moops->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
Moos (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moos->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::Accessor::PackedString (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessorPackedString->new; $o->attr1(42); $o }; $o->attr1
Object::Tiny::RW (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectTinyRW->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
Object::Tiny::XS (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectTinyXS->new(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
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
Class::Struct (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassStruct->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::Accessor (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessor->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
Class::Accessor::PackedString::Set (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessorPackedStringSet->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
Moose (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moose->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
Object::Tiny (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectTiny->new(attr1 => 42); $o }; $o->attr1
Object::Pad (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectPad->new; $o->set_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]
BENCHMARK SAMPLE RESULTS
Sample benchmark #1
Run on: perl: v5.38.2, CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (2 cores), OS: GNU/Linux Ubuntu version 20.04, OS kernel: Linux version 5.4.0-164-generic.
Benchmark command (default options):
% bencher -m Accessors::Get
Result formatted as table:
#table1#
+------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
| participant | rate (/s) | time (ns) | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples |
+------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
| Class::Accessor::PackedString::Set | 1740000 | 575 | 0.00% | 1678.82% | 2.6e-10 | 20 |
| Object::Tiny::RW | 2390000 | 418 | 37.66% | 1192.22% | 3.8e-10 | 20 |
| Class::Accessor | 2650000 | 377 | 52.51% | 1066.39% | 1.2e-10 | 20 |
| Simple::Accessor | 3300000 | 310 | 87.01% | 851.20% | 5.3e-10 | 20 |
| Class::InsideOut | 3400000 | 294 | 95.44% | 810.15% | 8.5e-11 | 20 |
| Class::Accessor::PackedString | 3440000 | 291 | 97.50% | 800.69% | 1.1e-10 | 21 |
| Object::Pad | 4210000 | 237 | 142.11% | 634.70% | 1.9e-10 | 20 |
| Class::XSAccessor::Array | 4000000 | 200 | 153.25% | 602.40% | 5.4e-09 | 21 |
| Class::Struct | 5100000 | 200 | 192.35% | 508.45% | 3.5e-10 | 20 |
| no generator (hash-based) | 5300000 | 190 | 204.11% | 484.93% | 3.3e-10 | 20 |
| Mojo::Base | 5500000 | 180 | 213.68% | 467.07% | 2.8e-10 | 20 |
| Object::Simple | 5700000 | 180 | 226.24% | 445.24% | 6.6e-10 | 20 |
| Moose | 6050000 | 165 | 247.56% | 411.81% | 1.5e-10 | 20 |
| no generator (array-based) | 6000000 | 170 | 247.69% | 411.61% | 2.9e-10 | 20 |
| Mo | 6100000 | 170 | 248.00% | 411.16% | 2.7e-10 | 21 |
| Class::Tiny | 6200000 | 161 | 256.49% | 398.99% | 7.6e-11 | 21 |
| Class::Accessor::Array | 6770000 | 148 | 289.48% | 356.72% | 6.6e-11 | 21 |
| Object::Tiny | 7200000 | 140 | 311.51% | 332.27% | 1.9e-10 | 20 |
| Mouse | 13000000 | 80 | 620.95% | 146.73% | 1.2e-10 | 20 |
| Moops | 14200000 | 70.4 | 717.18% | 117.68% | 6.2e-11 | 20 |
| Moo | 14000000 | 70 | 722.77% | 116.20% | 1e-10 | 20 |
| Moos | 15000000 | 69 | 734.24% | 113.23% | 7e-11 | 20 |
| Mojo::Base::XS | 14800000 | 67.7 | 748.89% | 109.55% | 4.9e-11 | 22 |
| Object::Tiny::RW::XS | 15000000 | 68 | 749.72% | 109.34% | 1.2e-10 | 21 |
| Object::Tiny::XS | 16000000 | 64 | 796.98% | 98.31% | 7.1e-11 | 20 |
| Class::XSAccessor | 16400000 | 60.8 | 845.17% | 88.20% | 2.1e-11 | 21 |
| raw hash access | 23500000 | 42.6 | 1248.39% | 31.92% | 3.7e-11 | 20 |
| raw array access | 31000000 | 32 | 1678.82% | 0.00% | 3.3e-11 | 20 |
+------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
The above result formatted in Benchmark.pm style:
Rate Class::Accessor::PackedString::Set Object::Tiny::RW Class::Accessor Simple::Accessor Class::InsideOut Class::Accessor::PackedString Object::Pad Class::XSAccessor::Array Class::Struct no generator (hash-based) Mojo::Base Object::Simple no generator (array-based) Mo Moose Class::Tiny Class::Accessor::Array Object::Tiny Mouse Moops Moo Moos Object::Tiny::RW::XS Mojo::Base::XS Object::Tiny::XS Class::XSAccessor raw hash access raw array access
Class::Accessor::PackedString::Set 1740000/s -- -27% -34% -46% -48% -49% -58% -65% -65% -66% -68% -68% -70% -70% -71% -72% -74% -75% -86% -87% -87% -88% -88% -88% -88% -89% -92% -94%
Object::Tiny::RW 2390000/s 37% -- -9% -25% -29% -30% -43% -52% -52% -54% -56% -56% -59% -59% -60% -61% -64% -66% -80% -83% -83% -83% -83% -83% -84% -85% -89% -92%
Class::Accessor 2650000/s 52% 10% -- -17% -22% -22% -37% -46% -46% -49% -52% -52% -54% -54% -56% -57% -60% -62% -78% -81% -81% -81% -81% -82% -83% -83% -88% -91%
Simple::Accessor 3300000/s 85% 34% 21% -- -5% -6% -23% -35% -35% -38% -41% -41% -45% -45% -46% -48% -52% -54% -74% -77% -77% -77% -78% -78% -79% -80% -86% -89%
Class::InsideOut 3400000/s 95% 42% 28% 5% -- -1% -19% -31% -31% -35% -38% -38% -42% -42% -43% -45% -49% -52% -72% -76% -76% -76% -76% -76% -78% -79% -85% -89%
Class::Accessor::PackedString 3440000/s 97% 43% 29% 6% 1% -- -18% -31% -31% -34% -38% -38% -41% -41% -43% -44% -49% -51% -72% -75% -75% -76% -76% -76% -78% -79% -85% -89%
Object::Pad 4210000/s 142% 76% 59% 30% 24% 22% -- -15% -15% -19% -24% -24% -28% -28% -30% -32% -37% -40% -66% -70% -70% -70% -71% -71% -72% -74% -82% -86%
Class::XSAccessor::Array 4000000/s 187% 108% 88% 55% 47% 45% 18% -- 0% -5% -9% -9% -15% -15% -17% -19% -26% -30% -60% -64% -65% -65% -65% -66% -68% -69% -78% -84%
Class::Struct 5100000/s 187% 108% 88% 55% 47% 45% 18% 0% -- -5% -9% -9% -15% -15% -17% -19% -26% -30% -60% -64% -65% -65% -65% -66% -68% -69% -78% -84%
no generator (hash-based) 5300000/s 202% 120% 98% 63% 54% 53% 24% 5% 5% -- -5% -5% -10% -10% -13% -15% -22% -26% -57% -62% -63% -63% -64% -64% -66% -68% -77% -83%
Mojo::Base 5500000/s 219% 132% 109% 72% 63% 61% 31% 11% 11% 5% -- 0% -5% -5% -8% -10% -17% -22% -55% -60% -61% -61% -62% -62% -64% -66% -76% -82%
Object::Simple 5700000/s 219% 132% 109% 72% 63% 61% 31% 11% 11% 5% 0% -- -5% -5% -8% -10% -17% -22% -55% -60% -61% -61% -62% -62% -64% -66% -76% -82%
no generator (array-based) 6000000/s 238% 145% 121% 82% 72% 71% 39% 17% 17% 11% 5% 5% -- 0% -2% -5% -12% -17% -52% -58% -58% -59% -60% -60% -62% -64% -74% -81%
Mo 6100000/s 238% 145% 121% 82% 72% 71% 39% 17% 17% 11% 5% 5% 0% -- -2% -5% -12% -17% -52% -58% -58% -59% -60% -60% -62% -64% -74% -81%
Moose 6050000/s 248% 153% 128% 87% 78% 76% 43% 21% 21% 15% 9% 9% 3% 3% -- -2% -10% -15% -51% -57% -57% -58% -58% -58% -61% -63% -74% -80%
Class::Tiny 6200000/s 257% 159% 134% 92% 82% 80% 47% 24% 24% 18% 11% 11% 5% 5% 2% -- -8% -13% -50% -56% -56% -57% -57% -57% -60% -62% -73% -80%
Class::Accessor::Array 6770000/s 288% 182% 154% 109% 98% 96% 60% 35% 35% 28% 21% 21% 14% 14% 11% 8% -- -5% -45% -52% -52% -53% -54% -54% -56% -58% -71% -78%
Object::Tiny 7200000/s 310% 198% 169% 121% 110% 107% 69% 42% 42% 35% 28% 28% 21% 21% 17% 14% 5% -- -42% -49% -50% -50% -51% -51% -54% -56% -69% -77%
Mouse 13000000/s 618% 422% 371% 287% 267% 263% 196% 150% 150% 137% 125% 125% 112% 112% 106% 101% 85% 75% -- -11% -12% -13% -15% -15% -19% -24% -46% -60%
Moops 14200000/s 716% 493% 435% 340% 317% 313% 236% 184% 184% 169% 155% 155% 141% 141% 134% 128% 110% 98% 13% -- 0% -1% -3% -3% -9% -13% -39% -54%
Moo 14000000/s 721% 497% 438% 342% 320% 315% 238% 185% 185% 171% 157% 157% 142% 142% 135% 129% 111% 100% 14% 0% -- -1% -2% -3% -8% -13% -39% -54%
Moos 15000000/s 733% 505% 446% 349% 326% 321% 243% 189% 189% 175% 160% 160% 146% 146% 139% 133% 114% 102% 15% 2% 1% -- -1% -1% -7% -11% -38% -53%
Object::Tiny::RW::XS 15000000/s 745% 514% 454% 355% 332% 327% 248% 194% 194% 179% 164% 164% 150% 150% 142% 136% 117% 105% 17% 3% 2% 1% -- 0% -5% -10% -37% -52%
Mojo::Base::XS 14800000/s 749% 517% 456% 357% 334% 329% 250% 195% 195% 180% 165% 165% 151% 151% 143% 137% 118% 106% 18% 3% 3% 1% 0% -- -5% -10% -37% -52%
Object::Tiny::XS 16000000/s 798% 553% 489% 384% 359% 354% 270% 212% 212% 196% 181% 181% 165% 165% 157% 151% 131% 118% 25% 10% 9% 7% 6% 5% -- -5% -33% -50%
Class::XSAccessor 16400000/s 845% 587% 520% 409% 383% 378% 289% 228% 228% 212% 196% 196% 179% 179% 171% 164% 143% 130% 31% 15% 15% 13% 11% 11% 5% -- -29% -47%
raw hash access 23500000/s 1249% 881% 784% 627% 590% 583% 456% 369% 369% 346% 322% 322% 299% 299% 287% 277% 247% 228% 87% 65% 64% 61% 59% 58% 50% 42% -- -24%
raw array access 31000000/s 1696% 1206% 1078% 868% 818% 809% 640% 525% 525% 493% 462% 462% 431% 431% 415% 403% 362% 337% 150% 120% 118% 115% 112% 111% 100% 89% 33% --
Legends:
Class::Accessor: participant=Class::Accessor
Class::Accessor::Array: participant=Class::Accessor::Array
Class::Accessor::PackedString: participant=Class::Accessor::PackedString
Class::Accessor::PackedString::Set: participant=Class::Accessor::PackedString::Set
Class::InsideOut: participant=Class::InsideOut
Class::Struct: participant=Class::Struct
Class::Tiny: participant=Class::Tiny
Class::XSAccessor: participant=Class::XSAccessor
Class::XSAccessor::Array: participant=Class::XSAccessor::Array
Mo: participant=Mo
Mojo::Base: participant=Mojo::Base
Mojo::Base::XS: participant=Mojo::Base::XS
Moo: participant=Moo
Moops: participant=Moops
Moos: participant=Moos
Moose: participant=Moose
Mouse: participant=Mouse
Object::Pad: participant=Object::Pad
Object::Simple: participant=Object::Simple
Object::Tiny: participant=Object::Tiny
Object::Tiny::RW: participant=Object::Tiny::RW
Object::Tiny::RW::XS: participant=Object::Tiny::RW::XS
Object::Tiny::XS: participant=Object::Tiny::XS
Simple::Accessor: participant=Simple::Accessor
no generator (array-based): participant=no generator (array-based)
no generator (hash-based): participant=no generator (hash-based)
raw array access: participant=raw array access
raw hash access: participant=raw hash access
The above result presented as chart:
To display as an interactive HTML table on a browser, you can add option --format html+datatables
.
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/Bencher-ScenarioBundle-Accessors.
SOURCE
Source repository is at https://github.com/perlancar/perl-Bencher-Scenarios-Accessors.
SEE ALSO
AUTHOR
perlancar <perlancar@cpan.org>
CONTRIBUTING
To contribute, you can send patches by email/via RT, or send pull requests on GitHub.
Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:
% prove -l
If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.
COPYRIGHT AND LICENSE
This software is copyright (c) 2024, 2017, 2016 by perlancar <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.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Bencher-ScenarioBundle-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.