Bencher::Scenario::ModuleInstalledTiny::module_installed - Benchmark module_installed() vs some others
This document describes version 0.003 of Bencher::Scenario::ModuleInstalledTiny::module_installed (from Perl distribution Bencher-Scenarios-ModuleInstalledTiny), released on 2020-01-09.
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) | vs_slowest | errors | samples | +-------------------------------------------+----------------------------------------------------------------+-----------+-----------+------------+---------+---------+ | Module::Load::Conditional::check_install | strict | 2400 | 420 | 1 | 6.9e-07 | 20 | | Module::Load::Conditional::check_install | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 28000 | 36 | 12 | 3.1e-07 | 21 | | Module::Path::More::module_path | strict | 44000 | 23 | 18 | 5.3e-08 | 20 | | Module::Path::More::module_path | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 44000 | 23 | 18 | 1.4e-07 | 20 | | require | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 50000 | 20 | 21 | 2.7e-08 | 20 | | Module::Installed::Tiny::module_installed | Bencher::Scenario::ModuleInstalledTiny::module_installed::Test | 62300 | 16 | 26 | 6.7e-09 | 20 | | Module::Installed::Tiny::module_installed | strict | 1410000 | 0.708 | 590 | 2.1e-10 | 20 | | require | strict | 3736000 | 0.2677 | 1561 | 1.2e-11 | 20 | +-------------------------------------------+----------------------------------------------------------------+-----------+-----------+------------+---------+---------+
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 (ms) | vs_slowest | errors | samples | +---------------------------+-----------+------------------------+------------+---------+---------+ | Module::Load::Conditional | 40.1 | 33.7 | 1 | 2.4e-05 | 20 | | Module::Path::More | 10 | 3.6 | 3.8 | 1.8e-05 | 20 | | Module::Installed::Tiny | 10.2 | 3.8 | 3.92 | 8.7e-06 | 23 | | perl -e1 (baseline) | 6.4 | 0 | 6.3 | 1.4e-05 | 21 | +---------------------------+-----------+------------------------+------------+---------+---------+
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.