NAME Bencher::Scenario::BinarySearch - Benchmark binary searching VERSION This document describes version 0.001 of Bencher::Scenario::BinarySearch (from Perl distribution Bencher-Scenario-BinarySearch), released on 2021-04-21. SYNOPSIS To run benchmark with default option: % bencher -m BinarySearch To run module startup overhead benchmark: % bencher --module-startup -m BinarySearch 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. List::BinarySearch::PP 0.25 List::BinarySearch::XS 0.09 BENCHMARK PARTICIPANTS * List::BinarySearch::PP-10k-num (perl_code) Code template: List::BinarySearch::PP::binsearch(sub {$a<=>$b}, int(10_000*rand()), \@Bencher::Scenario::BinarySearch::ary_10k_num) * List::BinarySearch::XS-10k-num (perl_code) Code template: List::BinarySearch::XS::binsearch(sub {$a<=>$b}, int(10_000*rand()), \@Bencher::Scenario::BinarySearch::ary_10k_num) * List::BinarySearch::PP-10k-num-tie (perl_code) Code template: List::BinarySearch::PP::binsearch(sub {$a<=>$b}, int(10_000*rand()), \@Bencher::Scenario::BinarySearch::ary_10k_num_tie) SAMPLE BENCHMARK RESULTS Run on: perl: *v5.30.0*, CPU: *Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (2 cores)*, OS: *GNU/Linux Ubuntu version 20.04*, OS kernel: *Linux version 5.3.0-64-generic*. Benchmark with default options ("bencher -m BinarySearch"): #table1# +------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+ | participant | rate (/s) | time (μs) | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples | +------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+ | List::BinarySearch::PP-10k-num-tie | 30000 | 33 | 0.00% | 3819.35% | 1.1e-07 | 20 | | List::BinarySearch::PP-10k-num | 91000 | 11 | 204.13% | 1188.72% | 1.7e-08 | 20 | | List::BinarySearch::XS-10k-num | 1170000 | 0.852 | 3819.35% | 0.00% | 3.9e-10 | 23 | +------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+ Benchmark module startup overhead ("bencher -m BinarySearch --module-startup"): #table2# +------------------------+-----------+-------------------+-----------------------+-----------------------+---------+---------+ | participant | time (ms) | mod_overhead_time | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples | +------------------------+-----------+-------------------+-----------------------+-----------------------+---------+---------+ | List::BinarySearch::PP | 11.6 | 5.1 | 0.00% | 79.04% | 4e-06 | 20 | | List::BinarySearch::XS | 9.17 | 2.67 | 26.76% | 41.24% | 7.4e-06 | 21 | | perl -e1 (baseline) | 6.5 | 0 | 79.04% | 0.00% | 4.2e-05 | 20 | +------------------------+-----------+-------------------+-----------------------+-----------------------+---------+---------+ To display as an interactive HTML table on a browser, you can add option "--format html+datatables". BENCHMARK NOTES List::BinarySearch::XS is an order of magnitude faster, but does not support tied arrays. On my laptop, binary searching a tied array is about three times faster than binary searching a regular array. HOMEPAGE Please visit the project's homepage at . SOURCE Source repository is at . BUGS Please report any bugs or feature requests on the bugtracker website 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. AUTHOR perlancar COPYRIGHT AND LICENSE This software is copyright (c) 2021 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.