NAME

Bencher::Scenario::LoggingModules::NullLogging - Benchmark logging statement that does not output anywhere (to measure logging overhead)

VERSION

This document describes version 0.003 of Bencher::Scenario::LoggingModules::NullLogging (from Perl distribution Bencher-Scenarios-LoggingModules), released on 2019-02-22.

SYNOPSIS

To run benchmark with default option:

% bencher -m LoggingModules::NullLogging

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.

Log::Any 1.707

Log::Contextual 0.007001

Log::Dispatch::Null 2.65

Log::Dispatchouli 2.015

Log::Fast v2.0.0

Log::Log4perl 1.49

Log::Log4perl::Tiny 1.4.0

Log::Mini 0.0.1

Log::ger 0.025

Log::ger::Plugin::OptAway 0.006

Mojo::Log

BENCHMARK PARTICIPANTS

  • Log::Any-no_adapter-100k_log_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::Any -e my $log = Log::Any->get_logger; for(1..100_000) { $log->trace(q[]) }
  • Log::Any-null_adapter-100k_log_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::Any -MLog::Any::Adapter -e Log::Any::Adapter->set(q[Null]); my $log = Log::Any->get_logger; for(1..100_000) { $log->trace(q[]) }
  • Log::Contextual+Log4perl-100k_trace (command)

    Command line:

    #TEMPLATE: #perl -e use Log::Contextual ":log", "set_logger"; use Log::Log4perl ":easy"; Log::Log4perl->easy_init($DEBUG); my $logger = Log::Log4perl->get_logger; set_logger $logger; for(1..100_000) { log_trace {} }
  • Log::Contextual+SimpleLogger-100k_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::Contextual::SimpleLogger -e use Log::Contextual ":log", -logger=>Log::Contextual::SimpleLogger->new({levels=>["debug"]}); for(1..100_000) { log_trace {} }
  • Log::Dispatch::Null-100k_debug (command)

    Command line:

    #TEMPLATE: #perl -MLog::Dispatch -e my $null = Log::Dispatch->new(outputs=>[["Null", min_level=>"debug"]]); for(1..100_000) { $null->debug("") }
  • Log::Dispatchouli-100k_debug (command)

    Command line:

    #TEMPLATE: #perl -MLog::Dispatchouli -e $logger = Log::Dispatchouli->new({ident=>"ident", facility=>"facility", to_stdout=>1, debug=>0}); for(1..100_000) { $logger->log_debug("") }
  • Log::Fast-100k_DEBUG (command)

    Command line:

    #TEMPLATE: #perl -MLog::Fast -e $LOG = Log::Fast->global; $LOG->level("INFO"); for(1..100_000) { $LOG->DEBUG(q()) }
  • Log::ger-100k_log_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::ger -e for(1..100_000) { log_trace(q[]) }
  • Log::ger+LGP:OptAway-100k_log_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::ger::Plugin=OptAway -MLog::ger -e for(1..100_000) { log_trace(q[]) }
  • Log::ger-1mil_log_trace (command) (not included by default)

    Command line:

    #TEMPLATE: #perl -MLog::ger -e for(1..1_000_000) { log_trace(q[]) }
  • Log::ger+LGP:OptAway-1mil_log_trace (command) (not included by default)

    Command line:

    #TEMPLATE: #perl -MLog::ger::Plugin=OptAway -MLog::ger -e for(1..1_000_000) { log_trace(q[]) }
  • Log::Log4perl-easy-100k_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::Log4perl=:easy -e Log::Log4perl->easy_init($ERROR); for(1..100_000) { TRACE "" }
  • Log::Log4perl::Tiny-100k_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::Log4perl::Tiny=:easy -e for(1..100_000) { TRACE "" }
  • Log::Mini-100k_trace (command)

    Command line:

    #TEMPLATE: #perl -MLog::Mini -e $log = Log::Mini->new("stderr"); for(1..100_000) { $log->trace(q[]) }
  • Mojo::Log-100k_debug (command)

    Command line:

    #TEMPLATE: #perl -MMojo::Log -e $log = Mojo::Log->new(level=>"warn"); for(1..100_000) { $log->debug("") }

SAMPLE BENCHMARK RESULTS

Run on: perl: v5.26.0, CPU: Intel(R) Core(TM) i5-2400 CPU @ 3.10GHz (4 cores), OS: GNU/Linux LinuxMint version 18.2, OS kernel: Linux version 4.8.0-53-generic.

Benchmark with default options (bencher -m LoggingModules::NullLogging):

#table1#
+-----------------------------------------+-----------+-------+------------+-----------+---------+
| participant                             | rate (/s) |  time | vs_slowest |  errors   | samples |
+-----------------------------------------+-----------+-------+------------+-----------+---------+
| Log::Dispatch::Null-100k_debug          |      0.59 | 1.7   |        1   |   0.013   |       7 |
| Log::Contextual+Log4perl-100k_trace     |      1.5  | 0.66  |        2.6 |   0.0031  |       7 |
| Log::Contextual+SimpleLogger-100k_trace |      1.6  | 0.64  |        2.6 |   0.0027  |       6 |
| Mojo::Log-100k_debug                    |      3.1  | 0.32  |        5.3 |   0.00088 |       6 |
| Log::Dispatchouli-100k_debug            |      4.7  | 0.21  |        7.9 |   0.00092 |       6 |
| Log::Log4perl::Tiny-100k_trace          |      7.4  | 0.14  |       12   |   0.00064 |       6 |
| Log::Mini-100k_trace                    |     11    | 0.088 |       19   |   0.00045 |       7 |
| Log::Any-null_adapter-100k_log_trace    |     13    | 0.078 |       22   |   0.00018 |       8 |
| Log::Log4perl-easy-100k_trace           |     15    | 0.067 |       25   |   0.00043 |       6 |
| Log::Fast-100k_DEBUG                    |     22    | 0.045 |       38   | 9.4e-05   |       8 |
| Log::Any-no_adapter-100k_log_trace      |     34    | 0.029 |       57   | 4.7e-05   |       6 |
| Log::ger+LGP:OptAway-100k_log_trace     |     40    | 0.02  |       70   |   0.00046 |       6 |
| Log::ger-100k_log_trace                 |     61    | 0.017 |      100   | 5.2e-05   |       6 |
+-----------------------------------------+-----------+-------+------------+-----------+---------+

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

BENCHMARK NOTES

You might notice that Log::ger+Log::ger::Plugin::OptAway (LGP:OptAway) is slower than plain Log::ger at 100k trace. This is because the plugin loading and setup overhead eclipses the gain provided by the OptAway plugin. If you try the these not-included-by-default participants they will show the benefit of OptAway:

Log::ger-1mil_log_trace
Log::ger+LGP:OptAway-1mil_log_trace

HOMEPAGE

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

SOURCE

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

BUGS

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

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) 2019 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.