NAME

Bencher::Scenario::List::Utils::MoveElement::move_element_to_beginning - Benchmark move_to_beginning()

VERSION

This document describes version 0.003 of Bencher::Scenario::List::Utils::MoveElement::move_element_to_beginning (from Perl distribution Bencher-Scenarios-List-Utils-MoveElement), released on 2021-07-23.

SYNOPSIS

To run benchmark with default option:

% bencher -m List::Utils::MoveElement::move_element_to_beginning

To run module startup overhead benchmark:

% bencher --module-startup -m List::Utils::MoveElement::move_element_to_beginning

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::Utils::MoveElement 0.02

List::Utils::MoveElement::PP

List::Utils::MoveElement::Splice

BENCHMARK PARTICIPANTS

  • List::Utils::MoveElement::move_element_to_beginning (perl_code)

    Function call template:

    List::Utils::MoveElement::move_element_to_beginning(<i>, @{<array>})
  • List::Utils::MoveElement::PP::to_beginning (perl_code)

    Function call template:

    List::Utils::MoveElement::PP::to_beginning(<i>, @{<array>})
  • List::Utils::MoveElement::Splice::to_beginning_copy (perl_code)

    Function call template:

    List::Utils::MoveElement::Splice::to_beginning_copy(<i>, @{<array>})
  • List::Utils::MoveElement::Splice::to_beginning_nocopy (perl_code)

    Function call template:

    List::Utils::MoveElement::Splice::to_beginning_nocopy(<i>, @{<array>})

BENCHMARK DATASETS

  • a1_1

  • a5_10

  • a500_1000

  • a5000_10000

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.30.2, 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 with default options (bencher -m List::Utils::MoveElement::move_element_to_beginning):

#table1#
+-------------------------------------------------------+-------------+------------+-----------+-----------------------+-----------------------+---------+---------+
| participant                                           | dataset     | rate (/s)  | time (μs) | pct_faster_vs_slowest | pct_slower_vs_fastest |  errors | samples |
+-------------------------------------------------------+-------------+------------+-----------+-----------------------+-----------------------+---------+---------+
| List::Utils::MoveElement::PP::to_beginning            | a5000_10000 |    1050    | 956       |                 0.00% |            180333.55% | 1.6e-07 |      20 |
| List::Utils::MoveElement::move_element_to_beginning   | a5000_10000 |    1050    | 955       |                 0.09% |            180164.76% | 2.1e-07 |      20 |
| List::Utils::MoveElement::Splice::to_beginning_copy   | a5000_10000 |    1231    | 812.5     |                17.62% |            153310.15% | 4.5e-08 |      28 |
| List::Utils::MoveElement::Splice::to_beginning_nocopy | a5000_10000 |    2280    | 439       |               117.57% |             82831.54% | 4.7e-08 |      26 |
| List::Utils::MoveElement::move_element_to_beginning   | a500_1000   |   10400    |  96.1     |               894.62% |             18040.98% | 2.1e-08 |      32 |
| List::Utils::MoveElement::PP::to_beginning            | a500_1000   |   10425.3  |  95.9204  |               896.24% |             18011.43% | 1.6e-11 |      20 |
| List::Utils::MoveElement::Splice::to_beginning_copy   | a500_1000   |   12269.75 |  81.50123 |              1072.50% |             15288.85% | 5.4e-12 |      23 |
| List::Utils::MoveElement::Splice::to_beginning_nocopy | a500_1000   |   20500    |  48.8     |              1856.65% |              9121.53% | 1.3e-08 |      21 |
| List::Utils::MoveElement::Splice::to_beginning_nocopy | a5_10       |  160320    |   6.2377  |             15219.68% |              1077.79% | 1.7e-11 |      20 |
| List::Utils::MoveElement::Splice::to_beginning_nocopy | a1_1        |  170000    |   5.88    |             16148.19% |              1010.48% | 1.3e-09 |      32 |
| List::Utils::MoveElement::PP::to_beginning            | a5_10       |  743000    |   1.35    |             70887.68% |               154.18% | 4.2e-10 |      20 |
| List::Utils::MoveElement::move_element_to_beginning   | a5_10       |  749830    |   1.3336  |             71553.16% |               151.82% | 5.6e-12 |      21 |
| List::Utils::MoveElement::Splice::to_beginning_copy   | a5_10       |  828680    |   1.2067  |             79088.58% |               127.85% | 5.5e-12 |      20 |
| List::Utils::MoveElement::Splice::to_beginning_copy   | a1_1        | 1900000    |   0.53    |            179509.88% |                 0.46% | 6.2e-10 |      20 |
| List::Utils::MoveElement::PP::to_beginning            | a1_1        | 1882000    |   0.5314  |            179715.00% |                 0.34% | 1.6e-11 |      20 |
| List::Utils::MoveElement::move_element_to_beginning   | a1_1        | 1900000    |   0.53    |            180333.55% |                 0.00% | 8.1e-10 |      21 |
+-------------------------------------------------------+-------------+------------+-----------+-----------------------+-----------------------+---------+---------+

Formatted as Benchmark.pm result:

                                Rate  LUMP:t_b a5000_10000  LUM:m_e_t_b a5000_10000  LUMS:t_b_c a5000_10000  LUMS:t_b_n a5000_10000  LUM:m_e_t_b a500_1000  LUMP:t_b a500_1000  LUMS:t_b_c a500_1000  LUMS:t_b_n a500_1000  LUMS:t_b_n a5_10  LUMS:t_b_n a1_1  LUMP:t_b a5_10  LUM:m_e_t_b a5_10  LUMS:t_b_c a5_10  LUMP:t_b a1_1  LUMS:t_b_c a1_1  LUM:m_e_t_b a1_1 
 LUMP:t_b a5000_10000         1050/s                    --                       0%                    -15%                    -54%                   -89%                -89%                  -91%                  -94%              -99%             -99%            -99%               -99%              -99%           -99%             -99%              -99% 
 LUM:m_e_t_b a5000_10000      1050/s                    0%                       --                    -14%                    -54%                   -89%                -89%                  -91%                  -94%              -99%             -99%            -99%               -99%              -99%           -99%             -99%              -99% 
 LUMS:t_b_c a5000_10000       1231/s                   17%                      17%                      --                    -45%                   -88%                -88%                  -89%                  -93%              -99%             -99%            -99%               -99%              -99%           -99%             -99%              -99% 
 LUMS:t_b_n a5000_10000       2280/s                  117%                     117%                     85%                      --                   -78%                -78%                  -81%                  -88%              -98%             -98%            -99%               -99%              -99%           -99%             -99%              -99% 
 LUM:m_e_t_b a500_1000       10400/s                  894%                     893%                    745%                    356%                     --                  0%                  -15%                  -49%              -93%             -93%            -98%               -98%              -98%           -99%             -99%              -99% 
 LUMP:t_b a500_1000        10425.3/s                  896%                     895%                    747%                    357%                     0%                  --                  -15%                  -49%              -93%             -93%            -98%               -98%              -98%           -99%             -99%              -99% 
 LUMS:t_b_c a500_1000     12269.75/s                 1072%                    1071%                    896%                    438%                    17%                 17%                    --                  -40%              -92%             -92%            -98%               -98%              -98%           -99%             -99%              -99% 
 LUMS:t_b_n a500_1000        20500/s                 1859%                    1856%                   1564%                    799%                    96%                 96%                   67%                    --              -87%             -87%            -97%               -97%              -97%           -98%             -98%              -98% 
 LUMS:t_b_n a5_10           160320/s                15226%                   15210%                  12925%                   6937%                  1440%               1437%                 1206%                  682%                --              -5%            -78%               -78%              -80%           -91%             -91%              -91% 
 LUMS:t_b_n a1_1            170000/s                16158%                   16141%                  13718%                   7365%                  1534%               1531%                 1286%                  729%                6%               --            -77%               -77%              -79%           -90%             -90%              -90% 
 LUMP:t_b a5_10             743000/s                70714%                   70640%                  60085%                  32418%                  7018%               7005%                 5937%                 3514%              362%             335%              --                -1%              -10%           -60%             -60%              -60% 
 LUM:m_e_t_b a5_10          749830/s                71585%                   71510%                  60825%                  32818%                  7106%               7092%                 6011%                 3559%              367%             340%              1%                 --               -9%           -60%             -60%              -60% 
 LUMS:t_b_c a5_10           828680/s                79124%                   79041%                  67232%                  36280%                  7863%               7848%                 6654%                 3944%              416%             387%             11%                10%                --           -55%             -56%              -56% 
 LUMP:t_b a1_1             1882000/s               179802%                  179613%                 152798%                  82511%                 17984%              17950%                15237%                 9083%             1073%            1006%            154%               150%              127%             --               0%                0% 
 LUMS:t_b_c a1_1           1900000/s               180277%                  180088%                 153201%                  82730%                 18032%              17998%                15277%                 9107%             1076%            1009%            154%               151%              127%             0%               --                0% 
 LUM:m_e_t_b a1_1          1900000/s               180277%                  180088%                 153201%                  82730%                 18032%              17998%                15277%                 9107%             1076%            1009%            154%               151%              127%             0%               0%                -- 

Legends:
  LUM:m_e_t_b a1_1: dataset=a1_1 participant=List::Utils::MoveElement::move_element_to_beginning
  LUM:m_e_t_b a5000_10000: dataset=a5000_10000 participant=List::Utils::MoveElement::move_element_to_beginning
  LUM:m_e_t_b a500_1000: dataset=a500_1000 participant=List::Utils::MoveElement::move_element_to_beginning
  LUM:m_e_t_b a5_10: dataset=a5_10 participant=List::Utils::MoveElement::move_element_to_beginning
  LUMP:t_b a1_1: dataset=a1_1 participant=List::Utils::MoveElement::PP::to_beginning
  LUMP:t_b a5000_10000: dataset=a5000_10000 participant=List::Utils::MoveElement::PP::to_beginning
  LUMP:t_b a500_1000: dataset=a500_1000 participant=List::Utils::MoveElement::PP::to_beginning
  LUMP:t_b a5_10: dataset=a5_10 participant=List::Utils::MoveElement::PP::to_beginning
  LUMS:t_b_c a1_1: dataset=a1_1 participant=List::Utils::MoveElement::Splice::to_beginning_copy
  LUMS:t_b_c a5000_10000: dataset=a5000_10000 participant=List::Utils::MoveElement::Splice::to_beginning_copy
  LUMS:t_b_c a500_1000: dataset=a500_1000 participant=List::Utils::MoveElement::Splice::to_beginning_copy
  LUMS:t_b_c a5_10: dataset=a5_10 participant=List::Utils::MoveElement::Splice::to_beginning_copy
  LUMS:t_b_n a1_1: dataset=a1_1 participant=List::Utils::MoveElement::Splice::to_beginning_nocopy
  LUMS:t_b_n a5000_10000: dataset=a5000_10000 participant=List::Utils::MoveElement::Splice::to_beginning_nocopy
  LUMS:t_b_n a500_1000: dataset=a500_1000 participant=List::Utils::MoveElement::Splice::to_beginning_nocopy
  LUMS:t_b_n a5_10: dataset=a5_10 participant=List::Utils::MoveElement::Splice::to_beginning_nocopy

Benchmark module startup overhead (bencher -m List::Utils::MoveElement::move_element_to_beginning --module-startup):

#table2#
+----------------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+
| participant                      | time (ms) | mod_overhead_time | pct_faster_vs_slowest | pct_slower_vs_fastest |  errors   | samples |
+----------------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+
| List::Utils::MoveElement         |      10   |               5.3 |                 0.00% |               143.56% |   0.00027 |      20 |
| List::Utils::MoveElement::PP     |      10   |               5.3 |                17.46% |               107.35% |   0.00025 |      20 |
| List::Utils::MoveElement::Splice |       5   |               0.3 |               114.09% |                13.77% |   0.00023 |      20 |
| perl -e1 (baseline)              |       4.7 |               0   |               143.56% |                 0.00% | 2.4e-05   |      20 |
+----------------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+

Formatted as Benchmark.pm result:

               Rate  LU:M  LUM:P  LUM:S  :perl -e1 ( 
 LU:M         0.1/s    --     0%   -50%         -53% 
 LUM:P        0.1/s    0%     --   -50%         -53% 
 LUM:S        0.2/s  100%   100%     --          -5% 
 :perl -e1 (  0.2/s  112%   112%     6%           -- 

Legends:
  :perl -e1 (: mod_overhead_time=0 participant=perl -e1 (baseline)
  LU:M: mod_overhead_time=5.3 participant=List::Utils::MoveElement
  LUM:P: mod_overhead_time=5.3 participant=List::Utils::MoveElement::PP
  LUM:S: mod_overhead_time=0.3 participant=List::Utils::MoveElement::Splice

To display as an interactive HTML table on a browser, you can add option --format html+datatables.

BENCHMARK NOTES

Using copy+splice+unshift (List::Utils::MoveElement::Splice) is faster. And we can get significantly faster still with larger list by avoiding copying @_.

HOMEPAGE

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

SOURCE

Source repository is at https://github.com/perlancar/perl-Bencher-Scenarios-List-Utils-MoveElement.

BUGS

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

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 <perlancar@cpan.org>

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.