Skip to content

Commit c7388f0

Browse files
author
Geoffrey Broadwell
committed
Prepare to support multiple summary output formats; default (and only) format for now is 'text'
1 parent e910fea commit c7388f0

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

bench

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,24 @@ my %TESTS = (
183183
},
184184
],
185185
);
186+
my %FORMATTER = (
187+
text => \&summarize_results,
188+
);
189+
186190

187191
MAIN();
188192

189193
sub MAIN {
190194
my %opt;
191-
GetOptions(\%opt, 'help|h|?!', 'man!')
195+
GetOptions(\%opt, 'help|h|?!', 'man!', 'format=s')
192196
or pod2usage(-verbose => 0);
193197
pod2usage(-verbose => 1) if $opt{help};
194198
pod2usage(-verbose => 2) if $opt{man};
195199

200+
$opt{format} ||= 'text';
201+
my $formatter = $FORMATTER{$opt{format}}
202+
or pod2usage(-msg => "Unknown output format '$opt{format}'");
203+
196204
my @results;
197205

198206
eval {
@@ -202,7 +210,7 @@ sub MAIN {
202210
};
203211
warn "\n$@\n" if $@;
204212

205-
summarize_results(\@results);
213+
$formatter->(\@results);
206214
}
207215

208216
sub run_tests {
@@ -426,7 +434,7 @@ bench -- Benchmark Perl-family compilers against each other
426434
427435
=head1 SYNOPSIS
428436
429-
bench [--help|-h|-?] [--man]
437+
bench [--help|-h|-?] [--man] [--format=text]
430438
431439
432440
=head1 DESCRIPTION
@@ -455,6 +463,11 @@ Get basic help for this program
455463
456464
Display this program's entire manpage
457465
466+
=item --format=text
467+
468+
Format the summary output in a particular format. The default is 'text',
469+
which outputs a text-rendered summary table, with ANSI coloring.
470+
458471
=back
459472
460473

0 commit comments

Comments
 (0)