NAME

Bencher::Scenario::DataSahParams::Validate - Measure validation speed

VERSION

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

SYNOPSIS

To run benchmark with default option:

% bencher -m DataSahParams::Validate

To run module startup overhead benchmark:

% bencher --module-startup -m DataSahParams::Validate

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.

Data::Sah::Params 0.003

Type::Params 1.000005

BENCHMARK PARTICIPANTS

  • dsp_int (perl_code) [int]

    Code template:

    state $check = Data::Sah::Params::compile("int*"); $check->(@{<args>})
  • tp_int (perl_code) [int]

    Code template:

    use Type::Params qw(compile); use Types::Standard qw(Int); state $check = compile(Int); $check->(@{<args>})
  • dsp_int_int[] (perl_code) [int_int[]]

    Code template:

    state $check = Data::Sah::Params::compile("int*", ["array*",of=>"int*"]); $check->(@{<args>})
  • tp_int_int[] (perl_code) [int_int[]]

    Code template:

    use Type::Params qw(compile); use Types::Standard qw(Int ArrayRef); state $check = compile(Int, ArrayRef[Int]); $check->(@{<args>})

BENCHMARK DATASETS

  • 1

  • 1,[]

  • 1,[1..10]

  • 1,[1..100]

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 default options (bencher -m DataSahParams::Validate):

#table1#
+---------------+------------+-----------+-----------+------------+---------+---------+
| participant   | dataset    | rate (/s) | time (μs) | vs_slowest |  errors | samples |
+---------------+------------+-----------+-----------+------------+---------+---------+
| dsp_int_int[] | 1,[1..100] |     24800 |  40.4     |    1       | 3.8e-08 |      22 |
| dsp_int_int[] | 1,[1..10]  |    130000 |   7.5     |    5.4     | 1.7e-08 |      20 |
| tp_int_int[]  | 1,[1..100] |    231807 |   4.31393 |    9.35713 |   0     |      20 |
| dsp_int_int[] | 1,[]       |    330000 |   3.1     |   13       | 3.3e-09 |      20 |
| tp_int_int[]  | 1,[1..10]  |    703000 |   1.42    |   28.4     | 3.6e-10 |      27 |
| tp_int_int[]  | 1,[]       |    990000 |   1       |   40       | 1.2e-09 |      22 |
| dsp_int       | 1          |   1420000 |   0.702   |   57.5     | 2.1e-10 |      20 |
| tp_int        | 1          |   1472000 |   0.6795  |   59.4     | 1.2e-11 |      20 |
+---------------+------------+-----------+-----------+------------+---------+---------+

Benchmark module startup overhead (bencher -m DataSahParams::Validate --module-startup):

#table2#
+---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+----------+---------+
| participant         | proc_private_dirty_size (MB) | proc_rss_size (MB) | proc_size (MB) | time (ms) | mod_overhead_time (ms) | vs_slowest |  errors  | samples |
+---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+----------+---------+
| Type::Params        | 0.96                         | 4.4                | 16             |      43   |                   37.3 |        1   |   0.0002 |      20 |
| Data::Sah::Params   | 5.4                          | 9.2                | 31             |       9.2 |                    3.5 |        4.7 | 4.4e-05  |      20 |
| perl -e1 (baseline) | 0.96                         | 4.4                | 16             |       5.7 |                    0   |        7.5 | 1.7e-05  |      20 |
+---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+----------+---------+

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

BENCHMARK NOTES

In this benchmark case, code generated by Data::Sah performs significantly more slowly because it is not particularly optimized. Future releases of Data::Sah will add some optimizations.

To see the source code generated by Data::Sah::Params, pass want_source => 1 option to compile(), e.g.:

compile({want_source=>1}, "int*", ...)

Or you can try on the command-line (the CLI utility is part of App::SahUtils):

% validate-with-sah '"int*"' -c

To see the source code generated by Type::Params, pass want_source => 1 option to compile() like in Data::Sah::Params, e.g.:

compile({want_source=>1}, Int, ...)

HOMEPAGE

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

SOURCE

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

BUGS

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

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.