NAME

Bencher::Scenario::Perl::Swap - Benchmark swapping two variables

VERSION

This document describes version 0.050 of Bencher::Scenario::Perl::Swap (from Perl distribution Bencher-Scenarios-Perl), released on 2019-10-20.

SYNOPSIS

To run benchmark with default option:

 % bencher -m Perl::Swap

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

DESCRIPTION

BENCHMARK PARTICIPANTS

  • my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a (perl_code)

    Code template:

     my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a = $b; $b = $tmp } [$a, $b]
  • my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) } (perl_code)

    Code template:

     my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) } [$a, $b]

BENCHMARK DATASETS

  • undef

  • empty-string

  • short-string

  • long-string

  • number

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.24.0, CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (4 cores), OS: GNU/Linux LinuxMint version 18.2, OS kernel: Linux version 4.8.0-53-generic.

Benchmark with default options (bencher -m Perl::Swap):

 #table1#
 +------------------------------------------------------------------+--------------+-----------+-----------+------------+---------+---------+
 | participant                                                      | dataset      | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +------------------------------------------------------------------+--------------+-----------+-----------+------------+---------+---------+
 | my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) }  | long-string  |  7872.179 |  127.0296 |    1       | 5.4e-12 |      20 |
 | my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) }  | empty-string |  7872.18  |  127.0296 |    1       | 5.5e-12 |      20 |
 | my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a | empty-string |  8947.86  |  111.759  |    1.13664 | 1.9e-11 |      20 |
 | my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a | long-string  |  9050     |  110      |    1.15    | 5.3e-08 |      20 |
 | my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a | short-string | 11200     |   89.2    |    1.42    | 2.7e-08 |      20 |
 | my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a | number       | 11400     |   87.5    |    1.45    | 2.1e-08 |      32 |
 | my $a = <a>; my $b = <b>; my $tmp; for (1..1001) { $tmp = $a; $a | undef        | 11000     |   87      |    1.5     | 1.1e-07 |      20 |
 | my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) }  | short-string | 13600     |   73.6    |    1.73    | 2.6e-08 |      21 |
 | my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) }  | number       | 14000     |   72      |    1.8     |   1e-07 |      21 |
 | my $a = <a>; my $b = <b>; for (1..1001) { ($a, $b) = ($b, $a) }  | undef        | 14000     |   70      |    1.8     | 8.3e-08 |      33 |
 +------------------------------------------------------------------+--------------+-----------+-----------+------------+---------+---------+

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-Perl.

SOURCE

Source repository is at https://github.com/perlancar/perl-Bencher-Scenarios-Perl.

BUGS

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

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) 2019, 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.