@@ -91,6 +91,11 @@ DEFINE_string(benchmark_color, "auto",
91
91
" environment variable is set to a terminal type that supports "
92
92
" colors." );
93
93
94
+ DEFINE_bool (benchmark_counters_tabular, false ,
95
+ " Whether to use tabular format when printing user counters to "
96
+ " the console. Valid values: 'true'/'yes'/1, 'false'/'no'/0."
97
+ " Defaults to false." );
98
+
94
99
DEFINE_int32 (v, 0 , " The level of verbose logging to output" );
95
100
96
101
namespace benchmark {
@@ -510,10 +515,10 @@ void RunBenchmarks(const std::vector<Benchmark::Instance>& benchmarks,
510
515
}
511
516
512
517
std::unique_ptr<BenchmarkReporter> CreateReporter (
513
- std::string const & name, ConsoleReporter::OutputOptions allow_color ) {
518
+ std::string const & name, ConsoleReporter::OutputOptions output_opts ) {
514
519
typedef std::unique_ptr<BenchmarkReporter> PtrType;
515
520
if (name == " console" ) {
516
- return PtrType (new ConsoleReporter (allow_color ));
521
+ return PtrType (new ConsoleReporter (output_opts ));
517
522
} else if (name == " json" ) {
518
523
return PtrType (new JSONReporter);
519
524
} else if (name == " csv" ) {
@@ -546,16 +551,21 @@ size_t RunSpecifiedBenchmarks(BenchmarkReporter* console_reporter,
546
551
std::unique_ptr<BenchmarkReporter> default_console_reporter;
547
552
std::unique_ptr<BenchmarkReporter> default_file_reporter;
548
553
if (!console_reporter) {
549
- auto output_opts = ConsoleReporter::OO_None;
550
- if (FLAGS_benchmark_color == " auto" )
551
- output_opts = IsColorTerminal () ? ConsoleReporter::OO_Color
552
- : ConsoleReporter::OO_None;
553
- else
554
- output_opts = IsTruthyFlagValue (FLAGS_benchmark_color)
555
- ? ConsoleReporter::OO_Color
556
- : ConsoleReporter::OO_None;
557
- default_console_reporter =
558
- internal::CreateReporter (FLAGS_benchmark_format, output_opts);
554
+ int output_opts = ConsoleReporter::OO_Defaults;
555
+ if ((FLAGS_benchmark_color == " auto" && IsColorTerminal ()) ||
556
+ IsTruthyFlagValue (FLAGS_benchmark_color)) {
557
+ output_opts |= ConsoleReporter::OO_Color;
558
+ } else {
559
+ output_opts &= ~ConsoleReporter::OO_Color;
560
+ }
561
+ if (FLAGS_benchmark_counters_tabular) {
562
+ output_opts |= ConsoleReporter::OO_Tabular;
563
+ } else {
564
+ output_opts &= ~ConsoleReporter::OO_Tabular;
565
+ }
566
+ default_console_reporter = internal::CreateReporter (
567
+ FLAGS_benchmark_format,
568
+ static_cast < ConsoleReporter::OutputOptions >(output_opts));
559
569
console_reporter = default_console_reporter.get ();
560
570
}
561
571
auto & Out = console_reporter->GetOutputStream ();
@@ -614,6 +624,7 @@ void PrintUsageAndExit() {
614
624
" [--benchmark_out=<filename>]\n "
615
625
" [--benchmark_out_format=<json|console|csv>]\n "
616
626
" [--benchmark_color={auto|true|false}]\n "
627
+ " [--benchmark_counters_tabular={true|false}]\n "
617
628
" [--v=<verbosity>]\n " );
618
629
exit (0 );
619
630
}
@@ -638,6 +649,8 @@ void ParseCommandLineFlags(int* argc, char** argv) {
638
649
// "color_print" is the deprecated name for "benchmark_color".
639
650
// TODO: Remove this.
640
651
ParseStringFlag (argv[i], " color_print" , &FLAGS_benchmark_color) ||
652
+ ParseBoolFlag (argv[i], " benchmark_counters_tabular" ,
653
+ &FLAGS_benchmark_counters_tabular) ||
641
654
ParseInt32Flag (argv[i], " v" , &FLAGS_v)) {
642
655
for (int j = i; j != *argc - 1 ; ++j) argv[j] = argv[j + 1 ];
643
656
0 commit comments