Bencher::Scenario::RegexpAssemble - Benchmark Regexp::Assemble
This document describes version 0.03 of Bencher::Scenario::RegexpAssemble (from Perl distribution Bencher-Scenario-RegexpAssemble), released on 2017-01-25.
To run benchmark with default option:
% bencher -m RegexpAssemble
To run module startup overhead benchmark:
% bencher --module-startup -m RegexpAssemble
For more options (dump scenario, list/include/exclude/add participants, list/include/exclude/add datasets, etc), see bencher or run bencher --help.
bencher --help
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.
Version numbers shown below are the versions used when running the sample benchmark.
Regexp::Assemble 0.37
assemble-with-ra (perl_code) [assembling]
Code template:
my $ra = Regexp::Assemble->new; for (1.. <num> ) { $ra->add(join("", map {$main::chars->[rand @$main::chars]} 1..10)) } $ra->re
assemble-raw (perl_code) [assembling]
my @strs; for (1.. <num> ) { push @strs, join("", map {$main::chars->[rand @$main::chars]} 1..10) } my $re = "\\A(?:".join("|", map {quotemeta} sort {length($b) <=> length($a)} @strs).")\\z"; $re = qr/$re/
match-with-ra (perl_code) [matching]
state $re = do { my $ra = Regexp::Assemble->new; for (1.. <num> ) { $ra->add(join("", map {$main::chars->[rand @$main::chars]} 1..10)) } $ra->re }; state $str = join("", map {$main::chars->[rand @$main::chars]} 1..10); $str =~ $re
match-raw (perl_code) [matching]
state $re = do { my @strs; for (1.. <num> ) { push @strs, join("", map {$main::chars->[rand @$main::chars]} 1..10) } my $re = "\\A(?:".join("|", map {quotemeta} sort {length($b) <=> length($a)} @strs).")\\z"; $re = qr/$re/ }; state $str = join("", map {$main::chars->[rand @$main::chars]} 1..10); $str =~ $re
10str
100str
1000str
10000str
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 RegexpAssemble):
bencher -m RegexpAssemble
#table1# +------------------+----------+-----------+---------------+------------+-----------+---------+ | participant | dataset | rate (/s) | time (ms) | vs_slowest | errors | samples | +------------------+----------+-----------+---------------+------------+-----------+---------+ | assemble-with-ra | 10000str | 2.1 | 470 | 1 | 0.0013 | 20 | | assemble-raw | 10000str | 18 | 56 | 8.3 | 0.00014 | 20 | | assemble-with-ra | 1000str | 22 | 46 | 10 | 0.00027 | 21 | | assemble-raw | 1000str | 200 | 5 | 90 | 6.7e-05 | 20 | | assemble-with-ra | 100str | 250 | 4 | 120 | 3.2e-05 | 20 | | assemble-raw | 100str | 2000 | 0.5 | 900 | 7.8e-06 | 20 | | assemble-with-ra | 10str | 2300 | 0.44 | 1100 | 4e-06 | 20 | | assemble-raw | 10str | 18000 | 0.055 | 8500 | 9.5e-08 | 25 | | match-with-ra | 10000str | 400000 | 0.003 | 200000 | 3.8e-08 | 20 | | match-with-ra | 1000str | 455000 | 0.0022 | 212000 | 8.1e-10 | 21 | | match-with-ra | 100str | 707000 | 0.00142 | 330000 | 4.7e-10 | 20 | | match-with-ra | 10str | 1820000 | 0.000551 | 847000 | 2e-10 | 22 | | match-raw | 1000str | 2480630 | 0.000403123 | 1157140 | 0 | 20 | | match-raw | 10000str | 2600000 | 0.000385 | 1210000 | 1.8e-10 | 30 | | match-raw | 100str | 2630000 | 0.00038 | 1230000 | 2.1e-10 | 20 | | match-raw | 10str | 2650000 | 0.000377 | 1240000 | 2.1e-10 | 20 | +------------------+----------+-----------+---------------+------------+-----------+---------+
Benchmark module startup overhead (bencher -m RegexpAssemble --module-startup):
bencher -m RegexpAssemble --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 | +---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+-----------+---------+ | Regexp::Assemble | 0.82 | 4.1 | 16 | 27 | 19.9 | 1 | 0.00011 | 20 | | perl -e1 (baseline) | 3.7 | 7.4 | 25 | 7.1 | 0 | 3.8 | 1.3e-05 | 20 | +---------------------+------------------------------+--------------------+----------------+-----------+------------------------+------------+-----------+---------+
To display as an interactive HTML table on a browser, you can add option --format html+datatables.
--format html+datatables
Please visit the project's homepage at https://metacpan.org/release/Bencher-Scenario-RegexpAssemble.
Source repository is at https://github.com/perlancar/perl-Bencher-Scenario-RegexpAssemble.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Bencher-Scenario-RegexpAssemble
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.
perlancar <perlancar@cpan.org>
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.
To install Bencher::Scenario::RegexpAssemble, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bencher::Scenario::RegexpAssemble
CPAN shell
perl -MCPAN -e shell install Bencher::Scenario::RegexpAssemble
For more information on module installation, please visit the detailed CPAN module installation guide.