Acme-CPANModules-TextTable

 view release on metacpan or  search on metacpan

lib/Acme/CPANModules/TextTable.pm  view on Meta::CPAN

            bench_code => sub {
                my ($table) = @_;
                Text::Table::CSV::table(rows=>$table, header_row=>1);
            },
            features => {
                wide_char_data => 1,
                color_data =>  0,
                box_char => {value=>undef, summary=>"Irrelevant"},
                multiline_data => {value=>1, summary=>"But make sure your CSV parser can handle multiline cell"},
            },
        },
        {
            module => 'Text::Table::HTML',
            bench_code => sub {
                my ($table) = @_;
                Text::Table::HTML::table(rows=>$table, header_row=>1);
            },
            features => {
                wide_char_data => 1,
                color_data =>  {value=>0, summary=>'Not converted to HTML color elements'},
                box_char => 0,
                multiline_data => 1,
            },
        },
        {
            module => 'Text::Table::HTML::DataTables',
            bench_code => sub {
                my ($table) = @_;
                Text::Table::HTML::DataTables::table(rows=>$table, header_row=>1);
            },
            features => {
                wide_char_data => 1,
                color_data =>  {value=>0, summary=>'Not converted to HTML color elements'},
                box_char => 0,
                multiline_data => 1,
            },
        },
        {
            module => 'Text::TabularDisplay',
            bench_code => sub {
                my ($table) = @_;
                my $t = Text::TabularDisplay->new(@{ $table->[0] });
                $t->add(@{ $table->[$_] }) for 1..@$table-1;
                $t->render; # doesn't add newline
            },
            features => {
                wide_char_data => 1,
                color_data =>  0,
                box_char => {value=>undef, summary=>"Irrelevant"},
                multiline_data => 1,
            },
        },
    ],

    bench_datasets => [
        {name=>'tiny (1x1)'          , argv => [_make_table( 1, 1)],},
        {name=>'small (3x5)'         , argv => [_make_table( 3, 5)],},
        {name=>'wide (30x5)'         , argv => [_make_table(30, 5)],},
        {name=>'long (3x300)'        , argv => [_make_table( 3, 300)],},
        {name=>'large (30x300)'      , argv => [_make_table(30, 300)],},
        {name=>'multiline data (2x1)', argv => [ [["col1", "col2"], ["foobar\nbaz\nqux\nquux","corge"]] ], include_by_default=>0 },
        {name=>'wide char data (1x2)', argv => [ [["col1"], ["no wide character"], ["宽字"]] ], include_by_default=>0 },
        {name=>'color data (1x2)'    , argv => [ [["col1"], ["no color"], ["\e[31m\e[1mwith\e[0m \e[32m\e[1mcolor\e[0m"]] ], include_by_default=>0 },
    ],

};

1;
# ABSTRACT: List of modules that generate text tables

__END__

=pod

=encoding UTF-8

=head1 NAME

Acme::CPANModules::TextTable - List of modules that generate text tables

=head1 VERSION

This document describes version 0.016 of Acme::CPANModules::TextTable (from Perl distribution Acme-CPANModules-TextTable), released on 2023-10-31.

=head1 SYNOPSIS

To run benchmark with default option:

 % bencher --cpanmodules-module TextTable

To run module startup overhead benchmark:

 % bencher --module-startup --cpanmodules-module TextTable

For more options (dump scenario, list/include/exclude/add participants, list/include/exclude/add datasets, etc), see L<bencher> or run C<bencher --help>.

=head1 DESCRIPTION

Currently excluded from this list are:

=over

=item * L<Text::SimpleTable::AutoWidth> (wrapper to L<Text::SimpleTable>);

=item * L<Text::ASCIITable::EasyTable> (wrapper to L<Text::ASCIITable>);

=back

=head1 ACME::CPANMODULES ENTRIES

=over

=item L<Text::Table::Any>

Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>

This is a frontend for many text table modules as backends. The interface is
dead simple, following L<Text::Table::Tiny>. The main drawback is that it
currently does not allow passing (some, any) options to each backend.


=item L<Text::SimpleTable>

Author: L<MRAMBERG|https://metacpan.org/author/MRAMBERG>

As its name implies, a simple table-generating module with minimal documentation
and a few choices or border characters. You have to set the width of all columns
manually.


=item L<Text::UnicodeBox::Table>

Author: L<EWATERS|https://metacpan.org/author/EWATERS>

The main feature of this module is the various border style it provides drawn
using Unicode box-drawing characters. It allows per-row style. The rendering
speed is particularly slow compared to other modules.


=item L<Text::Table::Manifold>

Author: L<RSAVAGE|https://metacpan.org/author/RSAVAGE>

Two main features of this module is per-column aligning and wide character
support. This module, aside from doing its rendering, can also be told to pass
rendering to HTML, CSV, or other text table module like
L<Text::UnicodeBox::Table>); so in this way it is similar to

lib/Acme/CPANModules/TextTable.pm  view on Meta::CPAN



=item * Text::Table::TinyColorWide (perl_code)

L<Text::Table::TinyColorWide>



=item * Text::Table::TinyWide (perl_code)

L<Text::Table::TinyWide>



=item * Text::Table::Org (perl_code)

L<Text::Table::Org>



=item * Text::Table::CSV (perl_code)

L<Text::Table::CSV>



=item * Text::Table::HTML (perl_code)

L<Text::Table::HTML>



=item * Text::Table::HTML::DataTables (perl_code)

L<Text::Table::HTML::DataTables>



=item * Text::TabularDisplay (perl_code)

L<Text::TabularDisplay>



=back

=head1 BENCHMARK DATASETS

=over

=item * tiny (1x1)

=item * small (3x5)

=item * wide (30x5)

=item * long (3x300)

=item * large (30x300)

=item * multiline data (2x1) (not included by default)

=item * wide char data (1x2) (not included by default)

=item * color data (1x2) (not included by default)

=back

=head1 BENCHMARK SAMPLE RESULTS

=head2 Sample benchmark #1

Run on: perl: I<< v5.38.0 >>, CPU: I<< Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz (2 cores) >>, OS: I<< GNU/Linux Ubuntu version 20.04 >>, OS kernel: I<< Linux version 5.4.0-164-generic >>.

Benchmark command (default options):

 % bencher --cpanmodules-module TextTable

Result formatted as table (split, part 1 of 5):

 #table1#
 {dataset=>"large (30x300)"}
 +-------------------------------+-----------+-----------+-----------------------+-----------------------+-----------+---------+
 | participant                   | rate (/s) | time (ms) | pct_faster_vs_slowest | pct_slower_vs_fastest |  errors   | samples |
 +-------------------------------+-----------+-----------+-----------------------+-----------------------+-----------+---------+
 | Text::UnicodeBox::Table       |      0.92 |    1100   |                 0.00% |             35566.44% |   0.0024  |      20 |
 | Text::ANSITable               |      1.8  |     560   |                94.68% |             18220.90% |   0.0012  |      20 |
 | Text::Table::More             |      2.5  |     400   |               167.94% |             13211.33% |   0.00094 |      20 |
 | Text::ASCIITable              |      9.6  |     100   |               934.43% |              3347.94% |   0.00076 |      20 |
 | Text::Table::TinyColorWide    |     10    |      70   |              1365.67% |              2333.45% |   0.0008  |      20 |
 | Text::FormatTable             |     15    |      69   |              1474.71% |              2164.95% |   0.00063 |      20 |
 | Text::Table::TinyWide         |     20    |      50   |              1927.24% |              1659.36% |   0.00058 |      20 |
 | Text::SimpleTable             |     26    |      38   |              2719.79% |              1164.86% |   0.00033 |      20 |
 | Text::Table::Manifold         |     30    |      30   |              3432.47% |               909.67% |   0.00039 |      20 |
 | Text::Table::Tiny             |     30    |      30   |              3660.87% |               848.36% |   0.00043 |      20 |
 | Text::TabularDisplay          |     40    |      30   |              4123.89% |               744.40% |   0.00046 |      20 |
 | Text::Table::HTML             |     50    |      20   |              4776.96% |               631.33% |   0.00036 |      20 |
 | Text::Table::TinyColor        |     50    |      20   |              5139.30% |               580.75% |   0.00056 |      20 |
 | Text::MarkdownTable           |     60    |      20   |              6854.90% |               412.82% |   0.00035 |      20 |
 | Text::Table                   |     90    |      10   |              9175.49% |               284.52% |   0.00026 |      20 |
 | Text::Table::HTML::DataTables |    100    |      10   |             10410.10% |               239.35% |   0.00018 |      20 |
 | Text::Table::TinyBorderStyle  |    200    |       6   |             19509.01% |                81.89% |   0.00011 |      20 |
 | Text::Table::Org              |    200    |       5   |             20190.87% |                75.78% |   0.00013 |      20 |
 | Text::Table::CSV              |    200    |       4.9 |             21769.21% |                63.09% | 4.3e-05   |      20 |
 | Text::Table::Sprintf          |    300    |       4   |             28690.71% |                23.88% | 7.4e-05   |      20 |
 | Text::Table::Any              |    300    |       3   |             35566.44% |                 0.00% | 3.3e-05   |      20 |
 +-------------------------------+-----------+-----------+-----------------------+-----------------------+-----------+---------+

The above result formatted in L<Benchmark.pm|Benchmark> style:

                                   Rate  Text::UnicodeBox::Table  Text::ANSITable  Text::Table::More  Text::ASCIITable  Text::Table::TinyColorWide  Text::FormatTable  Text::Table::TinyWide  Text::SimpleTable  Text::Table::Manifold  Text::Table::Tiny ...
  Text::UnicodeBox::Table        0.92/s                       --             -49%               -63%              -90%                        -93%               -93%                   -95%               -96%                   -97%               -97% ...
  Text::ANSITable                 1.8/s                      96%               --               -28%              -82%                        -87%               -87%                   -91%               -93%                   -94%               -94% ...
  Text::Table::More               2.5/s                     175%              39%                 --              -75%                        -82%               -82%                   -87%               -90%                   -92%               -92% ...
  Text::ASCIITable                9.6/s                    1000%             459%               300%                --                        -30%               -31%                   -50%               -62%                   -70%               -70% ...
  Text::Table::TinyColorWide       10/s                    1471%             700%               471%               42%                          --                -1%                   -28%               -45%                   -57%               -57% ...
  Text::FormatTable                15/s                    1494%             711%               479%               44%                          1%                 --                   -27%               -44%                   -56%               -56% ...
  Text::Table::TinyWide            20/s                    2100%            1019%               700%              100%                         39%                37%                     --               -24%                   -40%               -40% ...
  Text::SimpleTable                26/s                    2794%            1373%               952%              163%                         84%                81%                    31%                 --                   -21%               -21% ...
  Text::Table::Manifold            30/s                    3566%            1766%              1233%              233%                        133%               129%                    66%                26%                     --                 0% ...
  Text::Table::Tiny                30/s                    3566%            1766%              1233%              233%                        133%               129%                    66%                26%                     0%                 -- ...
  Text::TabularDisplay             40/s                    3566%            1766%              1233%              233%                        133%               129%                    66%                26%                     0%                 0% ...
  Text::Table::HTML                50/s                    5400%            2700%              1900%              400%                        250%               245%                   150%                89%                    50%                50% ...
  Text::Table::TinyColor           50/s                    5400%            2700%              1900%              400%                        250%               245%                   150%                89%                    50%                50% ...
  Text::MarkdownTable              60/s                    5400%            2700%              1900%              400%                        250%               245%                   150%                89%                    50%                50% ...
  Text::Table                      90/s                   10900%            5500%              3900%              900%                        600%               590%                   400%               280%                   200%               200% ...
  Text::Table::HTML::DataTables   100/s                   10900%            5500%              3900%              900%                        600%               590%                   400%               280%                   200%               200% ...
  Text::Table::TinyBorderStyle    200/s                   18233%            9233%              6566%             1566%                       1066%              1050%                   733%               533%                   400%               400% ...
  Text::Table::Org                200/s                   21900%           11100%              7900%             1900%                       1300%              1280%                   900%               660%                   500%               500% ...
  Text::Table::CSV                200/s                   22348%           11328%              8063%             1940%                       1328%              1308%                   920%               675%                   512%               512% ...
  Text::Table::Sprintf            300/s                   27400%           13900%              9900%             2400%                       1650%              1625%                  1150%               850%                   650%               650% ...
  Text::Table::Any                300/s                   36566%           18566%             13233%             3233%                       2233%              2200%                  1566%              1166%                   900%               900% ...
 
 Legends:
   Text::ANSITable: participant=Text::ANSITable



( run in 0.714 second using v1.01-cache-2.11-cpan-39bf76dae61 )