The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Bencher::Scenario::JSONDecodeRegexp - Benchmark JSON decoding

VERSION

This document describes version 0.003 of Bencher::Scenario::JSONDecodeRegexp (from Perl distribution Bencher-Scenarios-JSONDecodeRegexp), released on 2017-01-25.

SYNOPSIS

To run benchmark with default option:

 % bencher -m JSONDecodeRegexp

To run module startup overhead benchmark:

 % bencher --module-startup -m JSONDecodeRegexp

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.

JSON::Decode::Regexp 0.09

JSON::PP 2.27300

BENCHMARK PARTICIPANTS

  • JSON::Decode::Regexp::from_json (perl_code)

    Function call template:

     JSON::Decode::Regexp::from_json(<data>)
  • JSON::PP::decode (perl_code)

    Code template:

     state $json = JSON::PP->new->allow_nonref; $json->decode(<data>)

BENCHMARK DATASETS

  • str-a

    a 100-character string with some escape sequences

  • array0

  • array1

  • array10

  • array100

  • hash0

  • hash1

  • hash10

  • hash100

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.24.0, 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 bencher -m JSONDecodeRegexp --include-path archive/JSON-Decode-Regexp-0.03/lib --include-path archive/JSON-Decode-Regexp-0.04/lib --include-path archive/JSON-Decode-Regexp-0.06/lib --include-path archive/JSON-Decode-Regexp-0.07/lib --include-path archive/JSON-Decode-Regexp-0.09/lib --multimodver JSON::Decode::Regexp:

 #table1#
 {dataset=>"array0"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.06   |     11000 |     87    |        1   | 1.9e-07 |      24 |
 | JSON::Decode::Regexp::from_json | 0.03   |     17000 |     60    |        1.4 | 1.9e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.04   |     17000 |     60    |        1.4 | 1.9e-07 |      24 |
 | JSON::PP::decode                |        |    230000 |      4.3  |       20   | 1.1e-08 |      29 |
 | JSON::Decode::Regexp::from_json | 0.07   |    280000 |      3.6  |       24   | 6.7e-09 |      20 |
 | JSON::Decode::Regexp::from_json | 0.09   |    281000 |      3.56 |       24.5 | 1.5e-09 |      24 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table2#
 {dataset=>"array1"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.06   |     11000 |      94   |        1   | 4.5e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.03   |     15000 |      68   |        1.4 | 1.9e-07 |      24 |
 | JSON::Decode::Regexp::from_json | 0.04   |     16000 |      62   |        1.5 | 1.1e-07 |      20 |
 | JSON::PP::decode                |        |    130000 |       7.8 |       12   | 8.6e-09 |      27 |
 | JSON::Decode::Regexp::from_json | 0.07   |    160000 |       6.1 |       15   | 3.5e-08 |      20 |
 | JSON::Decode::Regexp::from_json | 0.09   |    180000 |       5.5 |       17   | 6.7e-09 |      20 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table3#
 {dataset=>"array10"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.03   |      7700 |     130   |       1    | 2.7e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.06   |      8700 |     110   |       1.1  | 2.1e-07 |      21 |
 | JSON::Decode::Regexp::from_json | 0.04   |     12000 |      86   |       1.5  | 1.1e-07 |      20 |
 | JSON::PP::decode                |        |     29000 |      35   |       3.7  | 5.3e-08 |      20 |
 | JSON::Decode::Regexp::from_json | 0.07   |     40000 |      30   |       5    | 4.9e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.09   |     39000 |      25.7 |       5.09 | 1.2e-08 |      24 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table4#
 {dataset=>"array100"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.03   |      1300 |       768 |       1    | 6.4e-07 |      20 |
 | JSON::PP::decode                |        |      3200 |       320 |       2.4  | 3.1e-06 |      20 |
 | JSON::Decode::Regexp::from_json | 0.06   |      3400 |       300 |       2.6  | 4.1e-07 |      22 |
 | JSON::Decode::Regexp::from_json | 0.04   |      3410 |       293 |       2.62 | 2.6e-07 |      21 |
 | JSON::Decode::Regexp::from_json | 0.09   |      4500 |       220 |       3.5  | 4.3e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.07   |      4700 |       210 |       3.6  | 2.4e-07 |      25 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table5#
 {dataset=>"hash0"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.06   |     11000 |      87   |       1    | 1.3e-07 |      21 |
 | JSON::Decode::Regexp::from_json | 0.04   |     17300 |      58   |       1.51 | 2.7e-08 |      20 |
 | JSON::Decode::Regexp::from_json | 0.03   |     19000 |      53   |       1.6  |   1e-07 |      21 |
 | JSON::PP::decode                |        |    230000 |       4.4 |      20    | 6.7e-09 |      20 |
 | JSON::Decode::Regexp::from_json | 0.09   |    333000 |       3   |      29.1  | 6.9e-10 |      29 |
 | JSON::Decode::Regexp::from_json | 0.07   |    380000 |       2.7 |      33    | 3.3e-09 |      20 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table6#
 {dataset=>"hash1"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.06   |      8900 |    110    |        1   | 3.6e-07 |      28 |
 | JSON::Decode::Regexp::from_json | 0.03   |     13000 |     74    |        1.5 | 1.1e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.04   |     14000 |     71    |        1.6 | 1.3e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.07   |     78000 |     13    |        8.8 | 2.7e-08 |      20 |
 | JSON::PP::decode                |        |     87000 |     12    |        9.7 | 1.2e-08 |      24 |
 | JSON::Decode::Regexp::from_json | 0.09   |    123000 |      8.16 |       13.7 | 3.2e-09 |      22 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table7#
 {dataset=>"hash10"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.03   |    4200   |   240     |    1       | 6.9e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.06   |    5100   |   190     |    1.2     | 2.6e-07 |      21 |
 | JSON::Decode::Regexp::from_json | 0.04   |    6200   |   160     |    1.5     | 3.9e-07 |      24 |
 | JSON::Decode::Regexp::from_json | 0.07   |   11000   |    88     |    2.7     | 1.1e-07 |      27 |
 | JSON::PP::decode                |        |   15000   |    69     |    3.5     | 8.4e-08 |      32 |
 | JSON::Decode::Regexp::from_json | 0.09   |   19302.4 |    51.807 |    4.58605 |   0     |      20 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table8#
 {dataset=>"hash100"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (ms) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.03   |       430 |     2.3   |       1    | 9.1e-06 |      25 |
 | JSON::Decode::Regexp::from_json | 0.06   |      1000 |     0.96  |       2.4  | 1.8e-06 |      20 |
 | JSON::Decode::Regexp::from_json | 0.04   |      1100 |     0.93  |       2.5  | 1.5e-06 |      20 |
 | JSON::Decode::Regexp::from_json | 0.07   |      1200 |     0.85  |       2.7  | 1.1e-06 |      20 |
 | JSON::PP::decode                |        |      1510 |     0.663 |       3.52 | 4.8e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.09   |      2070 |     0.482 |       4.84 | 2.6e-07 |      21 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

 #table9#
 {dataset=>"str-a"}
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | participant                     | modver | rate (/s) | time (μs) | vs_slowest |  errors | samples |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+
 | JSON::Decode::Regexp::from_json | 0.06   |      9200 | 110       |     1      | 2.1e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.04   |     13000 |  78       |     1.4    | 2.7e-07 |      20 |
 | JSON::Decode::Regexp::from_json | 0.03   |     14000 |  71       |     1.5    | 2.7e-07 |      28 |
 | JSON::PP::decode                |        |     16000 |  61       |     1.8    |   8e-08 |      20 |
 | JSON::Decode::Regexp::from_json | 0.07   |     80000 |  10       |     9      | 1.8e-07 |      31 |
 | JSON::Decode::Regexp::from_json | 0.09   |    107785 |   9.27774 |    11.7003 |   0     |      20 |
 +---------------------------------+--------+-----------+-----------+------------+---------+---------+

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

SOURCE

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

BUGS

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

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.