NAME

Bencher::Scenario::ArrayVsHashBuilding - Benchmark building array vs hash

VERSION

This document describes version 0.001 of Bencher::Scenario::ArrayVsHashBuilding (from Perl distribution Bencher-Scenario-ArrayVsHashBuilding), released on 2016-09-03.

SYNOPSIS

To run benchmark with default option:

% bencher -m ArrayVsHashBuilding

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

BENCHMARK PARTICIPANTS

  • array (perl_code)

    Code template:

    state $elems=<elems>; my $ary = []; for my $elem (@$elems) { push @$ary, $elems }; $ary
  • hash (perl_code)

    Code template:

    state $elems=<elems>; my $hash = {}; for my $elem (@$elems) { $hash->{$elem} = 1 }; $hash

BENCHMARK DATASETS

  • elems=1

  • elems=10

  • elems=100

  • elems=1000

  • elems=10000

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.22.1, CPU: Intel(R) Core(TM) M-5Y71 CPU @ 1.20GHz (2 cores), OS: GNU/Linux LinuxMint version 17.3, OS kernel: Linux version 3.19.0-32-generic.

Benchmark with default options (bencher -m ArrayVsHashBuilding):

#table1#
+-------------+-------------+-----------+-------------+------------+---------+---------+
| participant | dataset     | rate (/s) |   time (ms) | vs_slowest |  errors | samples |
+-------------+-------------+-----------+-------------+------------+---------+---------+
| hash        | elems=10000 |       504 | 1.98        |       1    | 6.1e-07 |      22 |
| array       | elems=10000 |      1310 | 0.764       |       2.6  | 2.1e-07 |      20 |
| hash        | elems=1000  |      5800 | 0.17        |      12    | 2.1e-07 |      20 |
| array       | elems=1000  |     12700 | 0.0786      |      25.2  | 2.6e-08 |      21 |
| hash        | elems=100   |     69900 | 0.0143      |     139    | 5.6e-09 |      28 |
| array       | elems=100   |    110000 | 0.009       |     220    |   1e-08 |      20 |
| hash        | elems=10    |    636229 | 0.00157176  |    1262.73 |   0     |      22 |
| array       | elems=10    |    744000 | 0.00134     |    1480    | 4.2e-10 |      20 |
| hash        | elems=1     |   2510000 | 0.000398    |    4990    | 5.1e-11 |      20 |
| array       | elems=1     |   2872660 | 0.000348109 |    5701.41 |   0     |      28 |
+-------------+-------------+-----------+-------------+------------+---------+---------+

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-Scenario-ArrayVsHashBuilding.

SOURCE

Source repository is at https://github.com/perlancar/perl-Bencher-Scenario-ArrayVsHashBuilding.

BUGS

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

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

Bencher::Scenario::HashBuilding

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.