Bencher::Scenario::ModuleInstalledTiny::module_installed - Benchmark module_installed() vs some others
This document describes version 0.004 of Bencher::Scenario::ModuleInstalledTiny::module_installed (from Perl distribution Bencher-Scenarios-ModuleInstalledTiny), released on 2020-01-14.
To run benchmark with default option:
% bencher -m ModuleInstalledTiny::module_installed
To run module startup overhead benchmark:
% bencher --module-startup -m ModuleInstalledTiny::module_installed
For more options (dump scenario, list/include/exclude/add participants, list/include/exclude/add datasets, etc), see bencher or run bencher --help.
bencher --help
This scenario benchmarks module_installed() vs some others for the task of checking whether a module "is available locally". There are several approaches (also described in Module::Installed::Tiny documentation):
module_installed()
check_install()
require()
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.
Module::Installed::Tiny 0.004
Module::Path::More 0.33
Module::Load::Conditional 0.68
Module::Installed::Tiny::module_installed (perl_code)
Function call template:
Module::Installed::Tiny::module_installed(<module>)
Module::Path::More::module_path (perl_code)
Module::Path::More::module_path(module => <module>)
Module::Load::Conditional::check_install (perl_code)
Module::Load::Conditional::check_install(module => <module>)
require (perl_code)
Code template:
eval { (my $pm = <module> . ".pm") =~ s!::!/!g; require $pm; 1 } ? 1:0
strict
Bencher::Scenario::ModuleInstalledTiny::module_installed::Test
Run on: perl: v5.30.0, CPU: Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (2 cores), OS: GNU/Linux Ubuntu version 19.04, OS kernel: Linux version 5.0.0-37-generic.
Benchmark with default options (bencher -m ModuleInstalledTiny::module_installed):
bencher -m ModuleInstalledTiny::module_installed
#table1# +-------------------------------------------+----------------------------------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+ | participant | dataset | rate (/s) | time (μs) | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples | +-------------------------------------------+----------------------------------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+ | Module::Load::Conditional::check_install | strict | 3300 | 300 | 0.00% | 155352.19% | 1.2e-06 | 20 | | Module::Load::Conditional::check_install | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 40000 | 25 | 1112.29% | 12722.99% | 2.7e-08 | 20 | | Module::Path::More::module_path | strict | 60100 | 16.6 | 1711.19% | 8482.85% | 6.2e-09 | 23 | | Module::Path::More::module_path | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 61400 | 16.3 | 1749.98% | 8302.89% | 5.8e-09 | 26 | | require | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 70000 | 14 | 2023.32% | 7221.19% | 2.7e-08 | 20 | | Module::Installed::Tiny::module_installed | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 85000 | 12 | 2471.21% | 5945.88% | 1.3e-08 | 21 | | Module::Installed::Tiny::module_installed | strict | 2032000 | 0.4922 | 61166.01% | 153.73% | 2.3e-11 | 20 | | require | strict | 5160000 | 0.194 | 155352.19% | 0.00% | 8.7e-11 | 31 | +-------------------------------------------+----------------------------------------------------------------+-----------+-----------+-----------------------+-----------------------+---------+---------+
Benchmark module startup overhead (bencher -m ModuleInstalledTiny::module_installed --module-startup):
bencher -m ModuleInstalledTiny::module_installed --module-startup
#table2# +---------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+ | participant | time (ms) | mod_overhead_time | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples | +---------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+ | Module::Load::Conditional | 31.1 | 24.2 | 0.00% | 349.93% | 2.6e-05 | 20 | | Module::Path::More | 10 | 3.1 | 199.48% | 50.24% | 0.00015 | 20 | | Module::Installed::Tiny | 9.43 | 2.53 | 229.74% | 36.45% | 7.6e-06 | 20 | | perl -e1 (baseline) | 6.9 | 0 | 349.93% | 0.00% | 3.2e-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-Scenarios-ModuleInstalledTiny.
Source repository is at https://github.com/perlancar/perl-Bencher-Scenario-ModuleInstalledTiny.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Bencher-Scenarios-ModuleInstalledTiny
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) 2020, 2017, 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.
To install Bencher::Scenarios::ModuleInstalledTiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Bencher::Scenarios::ModuleInstalledTiny
CPAN shell
perl -MCPAN -e shell install Bencher::Scenarios::ModuleInstalledTiny
For more information on module installation, please visit the detailed CPAN module installation guide.