#!perl

our $DATE = '2015-06-24'; # DATE
our $VERSION = '0.01'; # VERSION

use 5.010001;
use strict;
use warnings;

use App::BenchTextTableModules;
use Benchmark::Dumb qw(cmpthese);
use Module::Load;

# load the modules
for my $mod (keys %App::BenchTextTableModules::contestants) {
    load $mod;
}

# benchmark
for my $tn (sort keys %App::BenchTextTableModules::tables) {
    say "$tn table:";
    my %codes;
    for my $mod (keys %App::BenchTextTableModules::contestants) {
        $codes{$mod} = sub { $App::BenchTextTableModules::contestants{$mod}->(
            $App::BenchTextTableModules::tables{$tn},
        ) };
    }
    cmpthese(0, \%codes);
    say "";
}

# ABSTRACT: Benchmark Perl text table modules
# PODNAME: bench-text-table-modules

__END__

=pod

=encoding UTF-8

=head1 NAME

bench-text-table-modules - Benchmark Perl text table modules

=head1 VERSION

This document describes version 0.01 of bench-text-table-modules (from Perl distribution App-BenchTextTableModules), released on 2015-06-24.

=head1 SYNOPSIS

 % bench-text-table-modules

Sample of tables being generated (3x5 size shown here):

 Text::ANSITable (0.40):
 .--------+--------+--------.
 | col1   | col2   | col3   |
 +--------+--------+--------+
 | row1.1 | row1.2 | row1.3 |
 | row2.1 | row2.2 | row2.3 |
 | row3.1 | row3.2 | row3.3 |
 | row4.1 | row4.2 | row4.3 |
 | row5.1 | row5.2 | row5.3 |
 `--------+--------+--------'
 
 Text::ASCIITable (0.20):
 .--------------------------.
 | col1   | col2   | col3   |
 +--------+--------+--------+
 | row1.1 | row1.2 | row1.3 |
 | row2.1 | row2.2 | row2.3 |
 | row3.1 | row3.2 | row3.3 |
 | row4.1 | row4.2 | row4.3 |
 | row5.1 | row5.2 | row5.3 |
 '--------+--------+--------'
 
 Text::FormatTable (1.03):
 col1  |col2  |col3  
 row1.1|row1.2|row1.3
 row2.1|row2.2|row2.3
 row3.1|row3.2|row3.3
 row4.1|row4.2|row4.3
 row5.1|row5.2|row5.3
 
 Text::MarkdownTable (0.2.4):
 | col1   | col2   | col3   |
 |--------|--------|--------|
 | row1.1 | row1.2 | row1.3 |
 | row2.1 | row2.2 | row2.3 |
 | row3.1 | row3.2 | row3.3 |
 | row4.1 | row4.2 | row4.3 |
 | row5.1 | row5.2 | row5.3 |
 
 Text::Table (1.130):
 col1   col2   col3  
 row1.1 row1.2 row1.3
 row2.1 row2.2 row2.3
 row3.1 row3.2 row3.3
 row4.1 row4.2 row4.3
 row5.1 row5.2 row5.3
 
 Text::Table::Tiny (?):
 +--------+--------+--------+
 | col1   | col2   | col3   |
 +--------+--------+--------+
 | row1.1 | row1.2 | row1.3 |
 | row2.1 | row2.2 | row2.3 |
 | row3.1 | row3.2 | row3.3 |
 | row4.1 | row4.2 | row4.3 |
 | row5.1 | row5.2 | row5.3 |
 +--------+--------+--------+
 Text::TabularDisplay (1.38):
 +--------+--------+--------+
 | col1   | col2   | col3   |
 +--------+--------+--------+
 | row1.1 | row1.2 | row1.3 |
 | row2.1 | row2.2 | row2.3 |
 | row3.1 | row3.2 | row3.3 |
 | row4.1 | row4.2 | row4.3 |
 | row5.1 | row5.2 | row5.3 |
 +--------+--------+--------+

Sample output:

 0tiny(1x1) table:
                               Rate Text::ANSITable Text::ASCIITable   Text::Table Text::MarkdownTable Text::FormatTable Text::TabularDisplay Text::Table::Tiny
 Text::ANSITable      2884.7+-5.3/s              --           -61.2%        -79.5%              -83.4%            -85.8%               -90.9%            -96.5%
 Text::ASCIITable        7441+-12/s   157.97+-0.63%               --        -47.0%              -57.3%            -63.5%               -76.4%            -91.0%
 Text::Table            14053+-15/s       387.2+-1%     88.84+-0.36%            --              -19.4%            -31.0%               -55.4%            -83.0%
 Text::MarkdownTable    17428+-32/s     504.2+-1.6%     134.2+-0.57%  24.02+-0.26%                  --            -14.5%               -44.7%            -78.9%
 Text::FormatTable      20376+-22/s     606.3+-1.5%    173.81+-0.53%  44.99+-0.22%        16.91+-0.25%                --               -35.4%            -75.3%
 Text::TabularDisplay   31540+-66/s     993.4+-3.1%      323.8+-1.1% 124.44+-0.53%        80.97+-0.51%      54.79+-0.37%                   --            -61.8%
 Text::Table::Tiny     82483+-0.3/s    2759.4+-5.3%     1008.4+-1.8% 486.95+-0.62%       373.27+-0.88%     304.81+-0.44%        161.52+-0.55%                --
 
 1small(3x5) table:
                                 Rate Text::ANSITable Text::ASCIITable Text::FormatTable   Text::Table Text::TabularDisplay Text::MarkdownTable Text::Table::Tiny
 Text::ANSITable         713.6+-1.1/s              --           -59.6%            -82.7%        -86.1%               -91.2%              -91.5%            -98.2%
 Text::ASCIITable       1766.8+-2.4/s   147.58+-0.51%               --            -57.1%        -65.6%               -78.1%              -79.0%            -95.5%
 Text::FormatTable    4113.87+-0.86/s   476.47+-0.91%    132.84+-0.32%                --        -19.9%               -49.0%              -51.2%            -89.5%
 Text::Table            5133.2+-5.6/s     619.3+-1.4%     190.54+-0.5%      24.78+-0.14%            --               -36.4%              -39.1%            -86.9%
 Text::TabularDisplay   8065.5+-3.1/s    1030.2+-1.8%     356.5+-0.64%             96.1%  57.13+-0.18%                   --               -4.3%            -79.4%
 Text::MarkdownTable       8429+-15/s    1081.2+-2.8%      377.1+-1.1%      104.9+-0.37%  64.21+-0.35%          4.51+-0.19%                  --            -78.5%
 Text::Table::Tiny        39172+-20/s      5389.2+-9%     2117.1+-3.2%            852.2% 663.12+-0.92%               385.7%       364.73+-0.87%                --
 
 2wide(30x5) table:
                                 Rate Text::ANSITable Text::ASCIITable Text::FormatTable   Text::Table Text::TabularDisplay Text::MarkdownTable Text::Table::Tiny
 Text::ANSITable        85.71+-0.11/s              --           -55.6%            -80.8%        -88.4%               -93.9%              -96.7%            -98.9%
 Text::ASCIITable      193.13+-0.11/s   125.32+-0.31%               --            -56.8%        -73.9%               -86.3%              -92.5%            -97.6%
 Text::FormatTable      447.1+-0.29/s   421.63+-0.73%     131.51+-0.2%                --        -39.5%               -68.2%              -82.6%            -94.4%
 Text::Table             739.3+-1.2/s     762.5+-1.8%    282.81+-0.67%      65.36+-0.29%            --               -47.5%              -71.2%            -90.7%
 Text::TabularDisplay 1407.96+-0.53/s    1542.7+-2.1%           629.0%     214.91+-0.24%  90.45+-0.32%                   --              -45.1%            -82.4%
 Text::MarkdownTable    2564.4+-2.8/s      2891.9+-5%     1227.8+-1.6%     473.57+-0.73% 246.87+-0.69%         82.14+-0.21%                  --            -67.9%
 Text::Table::Tiny         7979+-38/s       9210+-46%        4032+-20%      1684.7+-8.6%   979.3+-5.4%          466.7+-2.7%         211.2+-1.5%                --
 
 3long(3x300) table:
                                 Rate Text::ANSITable Text::ASCIITable Text::FormatTable Text::TabularDisplay Text::MarkdownTable Text::Table Text::Table::Tiny
 Text::ANSITable      17.723+-0.016/s              --           -57.0%            -81.3%               -90.4%              -93.8%      -95.0%            -99.0%
 Text::ASCIITable     41.199+-0.024/s   132.46+-0.25%               --            -56.5%               -77.8%              -85.5%      -88.3%            -97.6%
 Text::FormatTable      94.62+-0.11/s   433.86+-0.79%     129.66+-0.3%                --               -48.9%              -66.7%      -73.2%            -94.5%
 Text::TabularDisplay  185.26+-0.31/s       945.3+-2%    349.67+-0.79%        95.8+-0.4%                   --              -34.8%      -47.6%            -89.3%
 Text::MarkdownTable   284.06+-0.52/s    1502.7+-3.3%      589.5+-1.3%     200.22+-0.65%         53.33+-0.38%                  --      -19.6%            -83.6%
 Text::Table           353.23+-0.56/s    1893.1+-3.6%      757.4+-1.4%     273.33+-0.73%         90.67+-0.44%         24.35+-0.3%          --            -79.7%
 Text::Table::Tiny      1735.9+-4.5/s       9695+-27%        4113+-11%      1734.7+-5.3%            837+-2.9%           511.1+-2% 391.4+-1.5%                --
 
 4large(30x300) table:
                                   Rate Text::ANSITable Text::ASCIITable Text::FormatTable Text::TabularDisplay Text::MarkdownTable   Text::Table Text::Table::Tiny
 Text::ANSITable       1.9351+-0.0017/s              --           -53.2%            -82.5%               -93.2%              -97.1%        -97.8%            -99.2%
 Text::ASCIITable       4.134+-0.0023/s   113.63+-0.22%               --            -62.5%               -85.4%              -93.7%        -95.4%            -98.3%
 Text::FormatTable    11.0313+-0.0068/s   470.07+-0.61%    166.85+-0.22%                --               -61.2%              -83.3%        -87.6%            -95.5%
 Text::TabularDisplay    28.41+-0.016/s    1368.2+-1.5%           587.2%     157.54+-0.21%                   --              -56.9%        -68.1%            -88.5%
 Text::MarkdownTable    65.974+-0.056/s    3309.4+-4.2%     1495.9+-1.6%     498.06+-0.63%        132.22+-0.24%                  --        -26.0%            -73.2%
 Text::Table               89.14+-0.2/s       4506+-11%     2056.2+-4.9%         708+-1.8%        213.75+-0.71%        35.11+-0.32%            --            -63.8%
 Text::Table::Tiny        246.5+-0.23/s      12639+-16%     5862.8+-6.5%      2134.6+-2.5%        767.66+-0.94%       273.63+-0.47% 176.55+-0.66%                --

=head1 SEE ALSO

=head1 HOMEPAGE

Please visit the project's homepage at L<https://metacpan.org/release/App-BenchTextTableModules>.

=head1 SOURCE

Source repository is at L<https://github.com/perlancar/perl-App-BenchTextTableModules>.

=head1 BUGS

Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=App-BenchTextTableModules>

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.

=head1 AUTHOR

perlancar <perlancar@cpan.org>

=head1 COPYRIGHT AND LICENSE

This software is copyright (c) 2015 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.

=cut
