NAME
Bencher::Scenario::Accessors::Set - Benchmark attribute write/set
VERSION
This document describes version 0.150 of Bencher::Scenario::Accessors::Set (from Perl distribution Bencher-Scenarios-Accessors), released on 2021-08-03.
SYNOPSIS
To run benchmark with default option:
% bencher -m Accessors::Set
To run module startup overhead benchmark:
% bencher --module-startup -m Accessors::Set
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.66
Class::Tiny 1.008
Class::XSAccessor 1.19
Mo 0.40
Mojo::Base::XS 0.07
Moo 2.004004
Moops 0.038
Moos 0.30
Moose 2.2015
Mouse v2.5.10
Object::Pad 0.46
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::ObjectTinyRW 0.132
Perl::Examples::Accessors::ObjectTinyRWXS 0.132
Perl::Examples::Accessors::SimpleAccessor 0.132
Simple::Accessor 1.13
BENCHMARK PARTICIPANTS
Class::Accessor::PackedString (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessorPackedString->new; $o }; $o->attr1(42)
Class::Accessor::Array (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessorArray->new; $o }; $o->attr1(42)
Mojo::Base (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::MojoBase->new; $o }; $o->attr1(42)
Simple::Accessor (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::SimpleAccessor->new; $o }; $o->attr1(42)
Object::Tiny::RW (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectTinyRW->new; $o }; $o->attr1(42)
Moose (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moose->new; $o }; $o->attr1(42)
Moos (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moos->new; $o }; $o->attr1(42)
Object::Pad (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectPad->new; $o }; $o->set_attr1(42)
Mouse (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Mouse->new; $o }; $o->attr1(42)
Mo (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Mo->new; $o }; $o->attr1(42)
Object::Simple (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectSimple->new; $o }; $o->attr1(42)
Moops (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moops->new; $o }; $o->attr1(42)
Class::Struct (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassStruct->new; $o }; $o->attr1(42)
Class::XSAccessor (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassXSAccessor->new; $o }; $o->attr1(42)
Object::Tiny::RW::XS (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ObjectTinyRWXS->new; $o }; $o->attr1(42)
no generator (array-based) (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Array->new; $o }; $o->attr1(42)
Moo (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Moo->new; $o }; $o->attr1(42)
Class::InsideOut (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassInsideOut->new; $o }; $o->attr1(42)
Mojo::Base::XS (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::MojoBaseXS->new; $o }; $o->attr1(42)
Class::Accessor (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessor->new; $o }; $o->attr1(42)
Class::Tiny (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassTiny->new; $o }; $o->attr1(42)
no generator (hash-based) (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Hash->new; $o }; $o->attr1(42)
Class::Accessor::PackedString::Set (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassAccessorPackedStringSet->new; $o }; $o->attr1(42)
Class::XSAccessor::Array (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::ClassXSAccessorArray->new; $o }; $o->attr1(42)
raw hash access (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Hash->new; $o }; $o->{attr1} = 42
raw array access (perl_code)
Code template:
state $o = do { my $o = Perl::Examples::Accessors::Array->new; $o }; $o->[0] = 42
BENCHMARK SAMPLE RESULTS
Sample benchmark #1
Run on: perl: v5.34.0, CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (4 cores), OS: GNU/Linux LinuxMint version 19, OS kernel: Linux version 5.3.0-68-generic.
Benchmark command (default options):
% bencher -m Accessors::Set
Result formatted as table:
#table1#
+------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
| participant | rate (/s) | time (ns) | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples |
+------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
| Simple::Accessor | 922000 | 1090 | 0.00% | 2929.69% | 4.1e-10 | 20 |
| Class::Accessor::PackedString::Set | 1730000 | 579 | 87.44% | 1516.37% | 2.5e-10 | 20 |
| Class::Accessor::PackedString | 2380000 | 419 | 158.70% | 1071.14% | 1.5e-10 | 31 |
| Class::Accessor | 2590000 | 386 | 181.28% | 977.11% | 9.8e-11 | 20 |
| Class::InsideOut | 3400000 | 290 | 269.54% | 719.86% | 3.1e-10 | 20 |
| Object::Pad | 4640000 | 216 | 403.39% | 501.86% | 2.9e-11 | 24 |
| Moose | 5120000 | 195 | 455.28% | 445.61% | 5.2e-11 | 20 |
| Object::Tiny::RW | 5270000 | 190 | 472.33% | 429.36% | 7e-11 | 20 |
| Class::Struct | 5390000 | 186 | 484.42% | 418.41% | 1.5e-10 | 20 |
| Class::Accessor::Array | 5800000 | 170 | 526.56% | 383.54% | 1.7e-10 | 20 |
| Mojo::Base | 5900000 | 170 | 537.32% | 375.38% | 3.1e-10 | 20 |
| Mo | 6400000 | 160 | 599.49% | 333.13% | 4.1e-10 | 21 |
| Object::Simple | 6600000 | 150 | 611.69% | 325.70% | 2.4e-10 | 20 |
| Class::Tiny | 6700000 | 150 | 625.50% | 317.60% | 2.1e-10 | 20 |
| no generator (hash-based) | 7000000 | 140 | 655.64% | 300.94% | 2.1e-10 | 24 |
| no generator (array-based) | 7480000 | 134 | 711.82% | 273.20% | 9.8e-11 | 20 |
| Mouse | 11200000 | 89.28 | 1115.36% | 149.28% | 5.5e-12 | 25 |
| Moops | 11000000 | 88 | 1134.75% | 145.37% | 2.2e-10 | 20 |
| Moos | 12000000 | 81 | 1237.15% | 126.58% | 2.2e-10 | 20 |
| Object::Tiny::RW::XS | 13000000 | 77 | 1310.03% | 114.87% | 2.4e-10 | 21 |
| Mojo::Base::XS | 13500000 | 74.3 | 1360.26% | 107.48% | 7e-11 | 20 |
| Moo | 13500000 | 74 | 1366.84% | 106.54% | 5.7e-11 | 20 |
| Class::XSAccessor | 15000000 | 68 | 1497.85% | 89.61% | 1.6e-10 | 20 |
| Class::XSAccessor::Array | 17000000 | 58 | 1771.16% | 61.91% | 2.1e-10 | 20 |
| raw hash access | 25000000 | 41 | 2579.11% | 13.09% | 2.4e-10 | 20 |
| raw array access | 28000000 | 36 | 2929.69% | 0.00% | 2e-10 | 26 |
+------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
The above result formatted in Benchmark.pm style:
Rate Simple::Accessor Class::Accessor::PackedString::Set Class::Accessor::PackedString Class::Accessor Class::InsideOut Object::Pad Moose Object::Tiny::RW Class::Struct Class::Accessor::Array Mojo::Base Mo Object::Simple Class::Tiny no generator (hash-based) no generator (array-based) Mouse Moops Moos Object::Tiny::RW::XS Mojo::Base::XS Moo Class::XSAccessor Class::XSAccessor::Array raw hash access raw array access
Simple::Accessor 922000/s -- -46% -61% -64% -73% -80% -82% -82% -82% -84% -84% -85% -86% -86% -87% -87% -91% -91% -92% -92% -93% -93% -93% -94% -96% -96%
Class::Accessor::PackedString::Set 1730000/s 88% -- -27% -33% -49% -62% -66% -67% -67% -70% -70% -72% -74% -74% -75% -76% -84% -84% -86% -86% -87% -87% -88% -89% -92% -93%
Class::Accessor::PackedString 2380000/s 160% 38% -- -7% -30% -48% -53% -54% -55% -59% -59% -61% -64% -64% -66% -68% -78% -78% -80% -81% -82% -82% -83% -86% -90% -91%
Class::Accessor 2590000/s 182% 50% 8% -- -24% -44% -49% -50% -51% -55% -55% -58% -61% -61% -63% -65% -76% -77% -79% -80% -80% -80% -82% -84% -89% -90%
Class::InsideOut 3400000/s 275% 99% 44% 33% -- -25% -32% -34% -35% -41% -41% -44% -48% -48% -51% -53% -69% -69% -72% -73% -74% -74% -76% -80% -85% -87%
Object::Pad 4640000/s 404% 168% 93% 78% 34% -- -9% -12% -13% -21% -21% -25% -30% -30% -35% -37% -58% -59% -62% -64% -65% -65% -68% -73% -81% -83%
Moose 5120000/s 458% 196% 114% 97% 48% 10% -- -2% -4% -12% -12% -17% -23% -23% -28% -31% -54% -54% -58% -60% -61% -62% -65% -70% -78% -81%
Object::Tiny::RW 5270000/s 473% 204% 120% 103% 52% 13% 2% -- -2% -10% -10% -15% -21% -21% -26% -29% -53% -53% -57% -59% -60% -61% -64% -69% -78% -81%
Class::Struct 5390000/s 486% 211% 125% 107% 55% 16% 4% 2% -- -8% -8% -13% -19% -19% -24% -27% -52% -52% -56% -58% -60% -60% -63% -68% -77% -80%
Class::Accessor::Array 5800000/s 541% 240% 146% 127% 70% 27% 14% 11% 9% -- 0% -5% -11% -11% -17% -21% -47% -48% -52% -54% -56% -56% -60% -65% -75% -78%
Mojo::Base 5900000/s 541% 240% 146% 127% 70% 27% 14% 11% 9% 0% -- -5% -11% -11% -17% -21% -47% -48% -52% -54% -56% -56% -60% -65% -75% -78%
Mo 6400000/s 581% 261% 161% 141% 81% 35% 21% 18% 16% 6% 6% -- -6% -6% -12% -16% -44% -44% -49% -51% -53% -53% -57% -63% -74% -77%
Object::Simple 6600000/s 626% 286% 179% 157% 93% 43% 30% 26% 24% 13% 13% 6% -- 0% -6% -10% -40% -41% -46% -48% -50% -50% -54% -61% -72% -76%
Class::Tiny 6700000/s 626% 286% 179% 157% 93% 43% 30% 26% 24% 13% 13% 6% 0% -- -6% -10% -40% -41% -46% -48% -50% -50% -54% -61% -72% -76%
no generator (hash-based) 7000000/s 678% 313% 199% 175% 107% 54% 39% 35% 32% 21% 21% 14% 7% 7% -- -4% -36% -37% -42% -44% -46% -47% -51% -58% -70% -74%
no generator (array-based) 7480000/s 713% 332% 212% 188% 116% 61% 45% 41% 38% 26% 26% 19% 11% 11% 4% -- -33% -34% -39% -42% -44% -44% -49% -56% -69% -73%
Mouse 11200000/s 1120% 548% 369% 332% 224% 141% 118% 112% 108% 90% 90% 79% 68% 68% 56% 50% -- -1% -9% -13% -16% -17% -23% -35% -54% -59%
Moops 11000000/s 1138% 557% 376% 338% 229% 145% 121% 115% 111% 93% 93% 81% 70% 70% 59% 52% 1% -- -7% -12% -15% -15% -22% -34% -53% -59%
Moos 12000000/s 1245% 614% 417% 376% 258% 166% 140% 134% 129% 109% 109% 97% 85% 85% 72% 65% 10% 8% -- -4% -8% -8% -16% -28% -49% -55%
Object::Tiny::RW::XS 13000000/s 1315% 651% 444% 401% 276% 180% 153% 146% 141% 120% 120% 107% 94% 94% 81% 74% 15% 14% 5% -- -3% -3% -11% -24% -46% -53%
Mojo::Base::XS 13500000/s 1367% 679% 463% 419% 290% 190% 162% 155% 150% 128% 128% 115% 101% 101% 88% 80% 20% 18% 9% 3% -- 0% -8% -21% -44% -51%
Moo 13500000/s 1372% 682% 466% 421% 291% 191% 163% 156% 151% 129% 129% 116% 102% 102% 89% 81% 20% 18% 9% 4% 0% -- -8% -21% -44% -51%
Class::XSAccessor 15000000/s 1502% 751% 516% 467% 326% 217% 186% 179% 173% 150% 150% 135% 120% 120% 105% 97% 31% 29% 19% 13% 9% 8% -- -14% -39% -47%
Class::XSAccessor::Array 17000000/s 1779% 898% 622% 565% 400% 272% 236% 227% 220% 193% 193% 175% 158% 158% 141% 131% 53% 51% 39% 32% 28% 27% 17% -- -29% -37%
raw hash access 25000000/s 2558% 1312% 921% 841% 607% 426% 375% 363% 353% 314% 314% 290% 265% 265% 241% 226% 117% 114% 97% 87% 81% 80% 65% 41% -- -12%
raw array access 28000000/s 2927% 1508% 1063% 972% 705% 500% 441% 427% 416% 372% 372% 344% 316% 316% 288% 272% 148% 144% 125% 113% 106% 105% 88% 61% 13% --
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::RW: participant=Object::Tiny::RW
Object::Tiny::RW::XS: participant=Object::Tiny::RW::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-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) 2021, 2017, 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.