Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Choose JSON prettification based on style setting (auto=pretty); this…
… closes multi-format output TODO
  • Loading branch information
Geoffrey Broadwell committed Jun 18, 2012
1 parent 03c3480 commit 68bbd89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 0 additions & 1 deletion TODO
Expand Up @@ -3,7 +3,6 @@
+ Options to list known languages, implementations, tests, etc.
+ Add Pugs to known compilers
+ Document data expected from each test, and analysis of results
+ Output to multiple formats: ANSI text, plain text, JSON, HTML
+ Option to show times/comparisons with and without startup time included
* More tests!
+ Find weak points in core design
Expand Down
14 changes: 10 additions & 4 deletions bench
Expand Up @@ -362,9 +362,14 @@ sub compare_times {
}

sub summarize_results_json {
my $times = shift;
my ($times, $style) = @_;

$style = 1 if $style eq 'auto';

my $encoder = JSON->new->utf8;
$encoder->pretty if $style;

my $json = JSON->new->utf8->pretty->encode($times);
my $json = $encoder->encode($times);

print $json;
}
Expand Down Expand Up @@ -611,8 +616,9 @@ highlight entries in the summary table; C<auto> turns on ANSI color whenever
the output is a TTY. For HTML output, this determines whether a CSS style
block is added to the HTML (element C<class> attributes are always output).
C<auto> defaults to adding CSS to full HTML documents (format C<html>), and
I<not> adding it to HTML snippets (format C<html_snippet>). Style settings
are ignored for JSON output (format <json>).
I<not> adding it to HTML snippets (format C<html_snippet>). If style is
on (or auto) for JSON output (format C<json>), the result will be
pretty-printed; otherwise it will be output in compact form.
=back
Expand Down

0 comments on commit 68bbd89

Please sign in to comment.