NAME

Bencher::Scenario::SprintfVsUnpack - Benchmark sprintf() vs unpack()

VERSION

This document describes version 0.001 of Bencher::Scenario::SprintfVsUnpack (from Perl distribution Bencher-Scenario-SprintfVsUnpack), released on 2017-04-16.

SYNOPSIS

To run benchmark with default option:

% bencher -m SprintfVsUnpack

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.

BENCHMARK PARTICIPANTS

  • sprintf (perl_code)

    Code template:

    state $data = <sprintf_data>; my $res; for (1..1000) { $res = sprintf(<sprintf_fmt>, $data) } $res
  • unpack (perl_code)

    Code template:

    state $data = chr(<unpack_data>); my $res; for (1..1000) { $res = unpack(<unpack_fmt>, $data) } $res

BENCHMARK DATASETS

  • binary-byte

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.24.0, CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz (4 cores), OS: GNU/Linux Debian version 8.5, OS kernel: Linux version 3.16.0-4-amd64.

Benchmark with default options (bencher -m SprintfVsUnpack):

#table1#
+-------------+-----------+-----------+------------+---------+---------+
| participant | rate (/s) | time (μs) | vs_slowest |  errors | samples |
+-------------+-----------+-----------+------------+---------+---------+
| unpack      |      6770 |       148 |       1    | 4.7e-08 |      26 |
| sprintf     |      9070 |       110 |       1.34 | 5.3e-08 |      20 |
+-------------+-----------+-----------+------------+---------+---------+

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

BENCHMARK NOTES

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/Bencher-Scenario-SprintfVsUnpack.

SOURCE

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

BUGS

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

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) 2017 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.