Acme-CPANModules-TextTable
view release on metacpan or search on metacpan
lib/Acme/CPANModules/TextTable.pm view on Meta::CPAN
},
{
module => 'Text::FormatTable',
bench_code => sub {
my ($table) = @_;
my $t = Text::FormatTable->new(join('|', ('l') x @{ $table->[0] }));
$t->head(@{ $table->[0] });
$t->row(@{ $table->[$_] }) for 1..@$table-1;
$t->render;
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 0,
multiline_data => 1,
},
},
{
module => 'Text::MarkdownTable',
bench_code => sub {
my ($table) = @_;
my $out = "";
my $t = Text::MarkdownTable->new(file => \$out);
my $fields = $table->[0];
foreach (1..@$table-1) {
my $row = $table->[$_];
$t->add( {
map { $fields->[$_] => $row->[$_] } 0..@$fields-1
});
}
$t->done;
$out;
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 0,
multiline_data => {value=>0, summary=>'Newlines stripped'},
},
},
{
module => 'Text::Table',
bench_code => sub {
my ($table) = @_;
my $t = Text::Table->new(@{ $table->[0] });
$t->load(@{ $table }[1..@$table-1]);
$t;
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => {value=>undef, summary=>'Does not draw borders'},
multiline_data => 1,
},
},
{
module => 'Text::Table::Tiny',
description => <<'_',
The simple and tiny table-generating module which I liked back in 2012 (v0.03).
It employs an sprintf() trick to generate a single row. This module started my
personal experiments creating other table-generating modules (at last count I've
created no fewer than 15 of them!).
_
bench_code => sub {
my ($table) = @_;
Text::Table::Tiny::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 1,
color_data => 1,
box_char => 1,
multiline_data => 0,
},
},
{
module => 'Text::Table::TinyBorderStyle',
bench_code => sub {
my ($table) = @_;
Text::Table::TinyBorderStyle::table(rows=>$table, header_row=>1);
},
features => {
wide_char_data => 0,
color_data => 0,
box_char => 1,
multiline_data => 0,
},
},
{
module => 'Text::Table::More',
description => <<'_',
A module I wrote in early 2021. Main distinguishing feature is support for
rowspan/clospan. I plan to add more features to this module on an as-needed
basic. This module is now preferred to <pm:Text::ANSITable>, although currently
it does not offer nearly as many formatting options as Text::ANSITable.
_
bench_code => sub {
my ($table) = @_;
Text::Table::More::generate_table(rows=>$table, header_row=>1);
},
features => {
align_cell => 1,
align_column => 1,
align_row => 1,
box_char => 1,
color_data => 1,
color_theme => 0,
colspan => 1,
custom_border => 1,
custom_color => 0,
multiline_data => 1,
rowspan => 1,
speed => "slow",
valign_cell => 1,
valign_column => 1,
valign_row => 1,
wide_char_data => 1,
column_width => 0, # todo
lib/Acme/CPANModules/TextTable.pm view on Meta::CPAN
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
L<Text::Table::Any>.
=item L<Text::ANSITable>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
This 2013 project was my take in creating a text table module that can handle
color, multiline text, wide characters. I also threw in various formatting
options, e.g. per-column/row/cell align/valign/pad/vpad, conditional formatting,
and so on. I even added a couple of features I never used: hiding rows and
specifying columns to display which can be in different order from the original
specified columns or can contain the same original columns multiple times. I
think this module offers the most formatting options on CPAN.
In early 2021, I needed colspan/rowspan and I implemented this in a new module:
L<Text::Table::Span> (later renamed to L<Text::Table::More>). I plan to add
this feature too to Text::ANSITable, but in the meantime I'm also adding more
formatting options which I need to Text::Table::More.
=item L<Text::ASCIITable>
Author: L<LUNATIC|https://metacpan.org/author/LUNATIC>
=item L<Text::FormatTable>
Author: L<TREY|https://metacpan.org/author/TREY>
=item L<Text::MarkdownTable>
Author: L<VOJ|https://metacpan.org/author/VOJ>
=item L<Text::Table>
Author: L<SHLOMIF|https://metacpan.org/author/SHLOMIF>
=item L<Text::Table::Tiny>
Author: L<NEILB|https://metacpan.org/author/NEILB>
The simple and tiny table-generating module which I liked back in 2012 (v0.03).
It employs an sprintf() trick to generate a single row. This module started my
personal experiments creating other table-generating modules (at last count I've
created no fewer than 15 of them!).
=item L<Text::Table::TinyBorderStyle>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::More>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
A module I wrote in early 2021. Main distinguishing feature is support for
rowspan/clospan. I plan to add more features to this module on an as-needed
basic. This module is now preferred to L<Text::ANSITable>, although currently
it does not offer nearly as many formatting options as Text::ANSITable.
=item L<Text::Table::Sprintf>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
A performant (see benchmark result) and lightweight (a page of code, no use of
modules at all), but with minimal extra features.
=item L<Text::Table::TinyColor>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::TinyColorWide>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::TinyWide>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::Org>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::CSV>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::HTML>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::Table::HTML::DataTables>
Author: L<PERLANCAR|https://metacpan.org/author/PERLANCAR>
=item L<Text::TabularDisplay>
Author: L<DARREN|https://metacpan.org/author/DARREN>
=back
lib/Acme/CPANModules/TextTable.pm view on Meta::CPAN
The above result formatted in L<Benchmark.pm|Benchmark> style:
Rate Text::UnicodeBox::Table Text::ANSITable Text::Table::More Text::ASCIITable Text::FormatTable Text::Table::TinyColorWide Text::Table::TinyBorderStyle Text::Table Text::Table::TinyWide Text::Table::Tin...
Text::UnicodeBox::Table 33/s -- -66% -70% -92% -95% -96% -96% -97% -97% -97...
Text::ANSITable 70/s 200% -- -9% -78% -85% -88% -90% -91% -91% -92...
Text::Table::More 100/s 233% 11% -- -75% -83% -86% -88% -90% -90% -91...
Text::ASCIITable 450/s 1263% 354% 309% -- -31% -45% -54% -60% -62% -63...
Text::FormatTable 650/s 1900% 566% 500% 46% -- -20% -33% -42% -44% -46...
Text::Table::TinyColorWide 830/s 2400% 733% 650% 83% 25% -- -16% -27% -30% -33...
Text::Table::TinyBorderStyle 900/s 2900% 900% 800% 120% 50% 19% -- -13% -17% -19...
Text::Table 1200/s 3348% 1049% 934% 152% 72% 37% 14% -- -4% -8...
Text::Table::TinyWide 1200/s 3514% 1104% 984% 165% 80% 44% 20% 4% -- -3...
Text::Table::Tiny 1000/s 3650% 1150% 1025% 175% 87% 49% 25% 8% 3% -...
Text::SimpleTable 1580/s 4639% 1479% 1321% 247% 136% 89% 57% 37% 31% 26...
Text::Table::Manifold 1700/s 4900% 1566% 1400% 266% 150% 100% 66% 44% 38% 33...
Text::TabularDisplay 2300/s 6718% 2172% 1945% 400% 240% 172% 127% 97% 88% 81...
Text::Table::TinyColor 2900/s 8471% 2757% 2471% 528% 328% 242% 185% 148% 137% 128...
Text::MarkdownTable 3400/s 9900% 3233% 2900% 633% 400% 300% 233% 190% 176% 166...
Text::Table::HTML 3370/s 10001% 3267% 2930% 640% 405% 304% 236% 192% 179% 169...
Text::Table::HTML::DataTables 4100/s 12400% 4066% 3650% 816% 525% 400% 316% 262% 245% 233...
Text::Table::Sprintf 5260/s 15689% 5163% 4636% 1057% 689% 531% 426% 357% 336% 321...
Text::Table::Org 7800/s 22976% 7592% 6823% 1592% 1053% 823% 669% 569% 538% 515...
Text::Table::CSV 11000/s 33990% 11263% 10127% 2400% 1604% 1263% 1036% 888% 843% 809...
Text::Table::Any 13300/s 39846% 13215% 11884% 2829% 1897% 1497% 1231% 1058% 1005% 965...
Legends:
Text::ANSITable: participant=Text::ANSITable
Text::ASCIITable: participant=Text::ASCIITable
Text::FormatTable: participant=Text::FormatTable
Text::MarkdownTable: participant=Text::MarkdownTable
Text::SimpleTable: participant=Text::SimpleTable
Text::Table: participant=Text::Table
Text::Table::Any: participant=Text::Table::Any
Text::Table::CSV: participant=Text::Table::CSV
Text::Table::HTML: participant=Text::Table::HTML
Text::Table::HTML::DataTables: participant=Text::Table::HTML::DataTables
Text::Table::Manifold: participant=Text::Table::Manifold
Text::Table::More: participant=Text::Table::More
Text::Table::Org: participant=Text::Table::Org
Text::Table::Sprintf: participant=Text::Table::Sprintf
Text::Table::Tiny: participant=Text::Table::Tiny
Text::Table::TinyBorderStyle: participant=Text::Table::TinyBorderStyle
Text::Table::TinyColor: participant=Text::Table::TinyColor
Text::Table::TinyColorWide: participant=Text::Table::TinyColorWide
Text::Table::TinyWide: participant=Text::Table::TinyWide
Text::TabularDisplay: participant=Text::TabularDisplay
Text::UnicodeBox::Table: participant=Text::UnicodeBox::Table
The above result presented as chart:
=begin html
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAtAAAAH4CAMAAABUnipoAAAJJmlDQ1BpY2MAAEiJlZVnUJNZF8fv8zzphUASQodQQ5EqJYCUEFoo0quoQOidUEVsiLgCK4qINEWQRQEXXJUia0UUC4uCAhZ0gywCyrpxFVFBWXDfGZ33HT+8/5l7z2/+c+bec8/5cAEgiINlwct7YlK6wNvJjhkYFMwE3yiMn5...
=end html
=head2 Sample benchmark #2
Benchmark command (benchmarking module startup overhead):
% bencher --cpanmodules-module TextTable --module-startup
Result formatted as table:
#table6#
+-------------------------------+-----------+----------------------+-----------------------+-----------------------+-----------+---------+
| participant | time (ms) | mod_overhead_time | pct_faster_vs_slowest | pct_slower_vs_fastest | errors | samples |
+-------------------------------+-----------+----------------------+-----------------------+-----------------------+-----------+---------+
| Text::UnicodeBox::Table | 190 | 181 | 0.00% | 2053.49% | 0.00061 | 20 |
| Text::Table::Manifold | 110 | 101 | 75.66% | 1125.93% | 0.00039 | 20 |
| Text::ANSITable | 48 | 39 | 286.81% | 456.73% | 0.00026 | 20 |
| Text::MarkdownTable | 46 | 37 | 301.84% | 435.91% | 0.00031 | 21 |
| Text::Table::TinyColorWide | 40 | 31 | 366.96% | 361.18% | 0.00029 | 20 |
| Text::Table::TinyWide | 36 | 27 | 413.28% | 319.56% | 0.00014 | 22 |
| Text::Table::More | 28 | 19 | 553.94% | 229.31% | 0.00019 | 20 |
| Text::Table | 28 | 19 | 568.31% | 222.23% | 0.00027 | 20 |
| Text::ASCIITable | 20 | 11 | 781.19% | 144.38% | 0.00028 | 20 |
| Text::Table::Tiny | 21 | 12 | 795.31% | 140.53% | 0.00017 | 20 |
| Text::Table::TinyColor | 20 | 11 | 951.17% | 104.87% | 0.00042 | 21 |
| Text::FormatTable | 17 | 8 | 988.23% | 97.89% | 0.00017 | 20 |
| Text::Table::Any | 10 | 1 | 1195.57% | 66.22% | 0.00021 | 20 |
| Text::Table::TinyBorderStyle | 10 | 1 | 1201.51% | 65.46% | 0.00019 | 21 |
| Text::TabularDisplay | 10 | 1 | 1342.19% | 49.32% | 0.0002 | 20 |
| Text::Table::Org | 10 | 1 | 1396.46% | 43.91% | 0.0002 | 20 |
| Text::Table::HTML | 10 | 1 | 1400.52% | 43.52% | 0.00019 | 20 |
| Text::SimpleTable | 12 | 3 | 1421.63% | 41.53% | 0.00011 | 20 |
| Text::Table::HTML::DataTables | 10 | 1 | 1463.78% | 37.71% | 0.00012 | 20 |
| Text::Table::Sprintf | 9.1 | 0.0999999999999996 | 1954.13% | 4.84% | 7.3e-05 | 20 |
| Text::Table::CSV | 8.7 | -0.300000000000001 | 2029.97% | 1.10% | 3.8e-05 | 20 |
| perl -e1 (baseline) | 9 | 0 | 2053.49% | 0.00% | 8.9e-05 | 20 |
+-------------------------------+-----------+----------------------+-----------------------+-----------------------+-----------+---------+
The above result formatted in L<Benchmark.pm|Benchmark> style:
Rate Text::UnicodeBox::Table Text::Table::Manifold Text::ANSITable Text::MarkdownTable Text::Table::TinyColorWide Text::Table::TinyWide Text::Table::More Text::Table Text::Table::Tiny Text::ASCIITable Te...
Text::UnicodeBox::Table 5.3/s -- -42% -74% -75% -78% -81% -85% -85% -88% -89% ...
Text::Table::Manifold 9.1/s 72% -- -56% -58% -63% -67% -74% -74% -80% -81% ...
Text::ANSITable 20.8/s 295% 129% -- -4% -16% -25% -41% -41% -56% -58% ...
Text::MarkdownTable 21.7/s 313% 139% 4% -- -13% -21% -39% -39% -54% -56% ...
Text::Table::TinyColorWide 25.0/s 375% 175% 19% 14% -- -9% -30% -30% -47% -50% ...
Text::Table::TinyWide 27.8/s 427% 205% 33% 27% 11% -- -22% -22% -41% -44% ...
Text::Table::More 35.7/s 578% 292% 71% 64% 42% 28% -- 0% -25% -28% ...
Text::Table 35.7/s 578% 292% 71% 64% 42% 28% 0% -- -25% -28% ...
Text::Table::Tiny 47.6/s 804% 423% 128% 119% 90% 71% 33% 33% -- -4% ...
Text::ASCIITable 50.0/s 850% 450% 140% 129% 100% 80% 39% 39% 5% -- ...
Text::Table::TinyColor 50.0/s 850% 450% 140% 129% 100% 80% 39% 39% 5% 0% ...
Text::FormatTable 58.8/s 1017% 547% 182% 170% 135% 111% 64% 64% 23% 17% ...
Text::SimpleTable 83.3/s 1483% 816% 300% 283% 233% 200% 133% 133% 75% 66% ...
Text::Table::Any 100.0/s 1800% 1000% 380% 359% 300% 260% 179% 179% 110% 100% ...
Text::Table::TinyBorderStyle 100.0/s 1800% 1000% 380% 359% 300% 260% 179% 179% 110% 100% ...
Text::TabularDisplay 100.0/s 1800% 1000% 380% 359% 300% 260% 179% 179% 110% 100% ...
Text::Table::Org 100.0/s 1800% 1000% 380% 359% 300% 260% 179% 179% 110% 100% ...
Text::Table::HTML 100.0/s 1800% 1000% 380% 359% 300% 260% 179% 179% 110% 100% ...
Text::Table::HTML::DataTables 100.0/s 1800% 1000% 380% 359% 300% 260% 179% 179% 110% 100% ...
Text::Table::Sprintf 109.9/s 1987% 1108% 427% 405% 339% 295% 207% 207% 130% 119% ...
perl -e1 (baseline) 111.1/s 2011% 1122% 433% 411% 344% 300% 211% 211% 133% 122% ...
Text::Table::CSV 114.9/s 2083% 1164% 451% 428% 359% 313% 221% 221% 141% 129% ...
Legends:
Text::ANSITable: mod_overhead_time=39 participant=Text::ANSITable
( run in 2.045 seconds using v1.01-cache-2.11-cpan-5623c5533a1 )