Commit 02f409a7 by Dominic Hamon

Only output optional fields if they're set

parent 9fa66eb1
...@@ -64,9 +64,9 @@ DEFINE_int32(benchmark_repetitions, 1, ...@@ -64,9 +64,9 @@ DEFINE_int32(benchmark_repetitions, 1,
"The number of runs of each benchmark. If greater than 1, the " "The number of runs of each benchmark. If greater than 1, the "
"mean and standard deviation of the runs will be reported."); "mean and standard deviation of the runs will be reported.");
DEFINE_string(benchmark_format, "tabular", DEFINE_string(benchmark_format, "console",
"The format to use for console output. Valid values are " "The format to use for console output. Valid values are "
"'tabular', 'json', or 'csv'."); "'console', 'json', or 'csv'.");
DEFINE_bool(color_print, true, "Enables colorized logging."); DEFINE_bool(color_print, true, "Enables colorized logging.");
...@@ -828,7 +828,7 @@ void RunMatchingBenchmarks(const std::string& spec, ...@@ -828,7 +828,7 @@ void RunMatchingBenchmarks(const std::string& spec,
std::unique_ptr<BenchmarkReporter> GetDefaultReporter() { std::unique_ptr<BenchmarkReporter> GetDefaultReporter() {
typedef std::unique_ptr<BenchmarkReporter> PtrType; typedef std::unique_ptr<BenchmarkReporter> PtrType;
if (FLAGS_benchmark_format == "tabular") { if (FLAGS_benchmark_format == "console") {
return PtrType(new ConsoleReporter); return PtrType(new ConsoleReporter);
} else if (FLAGS_benchmark_format == "json") { } else if (FLAGS_benchmark_format == "json") {
return PtrType(new JSONReporter); return PtrType(new JSONReporter);
...@@ -874,7 +874,7 @@ void PrintUsageAndExit() { ...@@ -874,7 +874,7 @@ void PrintUsageAndExit() {
" [--benchmark_filter=<regex>]\n" " [--benchmark_filter=<regex>]\n"
" [--benchmark_min_time=<min_time>]\n" " [--benchmark_min_time=<min_time>]\n"
" [--benchmark_repetitions=<num_repetitions>]\n" " [--benchmark_repetitions=<num_repetitions>]\n"
" [--benchmark_format=<tabular|json|csv>]\n" " [--benchmark_format=<console|json|csv>]\n"
" [--color_print={true|false}]\n" " [--color_print={true|false}]\n"
" [--v=<verbosity>]\n"); " [--v=<verbosity>]\n");
exit(0); exit(0);
...@@ -906,7 +906,7 @@ void ParseCommandLineFlags(int* argc, char** argv) { ...@@ -906,7 +906,7 @@ void ParseCommandLineFlags(int* argc, char** argv) {
} }
} }
if (FLAGS_benchmark_format != "tabular" && if (FLAGS_benchmark_format != "console" &&
FLAGS_benchmark_format != "json" && FLAGS_benchmark_format != "json" &&
FLAGS_benchmark_format != "csv") { FLAGS_benchmark_format != "csv") {
PrintUsageAndExit(); PrintUsageAndExit();
......
...@@ -99,6 +99,7 @@ void ConsoleReporter::PrintRunData(const Run& result) { ...@@ -99,6 +99,7 @@ void ConsoleReporter::PrintRunData(const Run& result) {
ColorPrintf(COLOR_GREEN, "%-*s ", ColorPrintf(COLOR_GREEN, "%-*s ",
name_field_width_, result.benchmark_name.c_str()); name_field_width_, result.benchmark_name.c_str());
if (result.iterations == 0) { if (result.iterations == 0) {
ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ", ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ",
result.real_accumulated_time * multiplier, result.real_accumulated_time * multiplier,
...@@ -114,11 +115,22 @@ void ConsoleReporter::PrintRunData(const Run& result) { ...@@ -114,11 +115,22 @@ void ConsoleReporter::PrintRunData(const Run& result) {
(static_cast<double>(result.iterations)), (static_cast<double>(result.iterations)),
timeLabel); timeLabel);
} }
ColorPrintf(COLOR_CYAN, "%10lld", result.iterations); ColorPrintf(COLOR_CYAN, "%10lld", result.iterations);
ColorPrintf(COLOR_DEFAULT, "%*s %*s %s\n",
13, rate.c_str(), if (!rate.empty()) {
18, items.c_str(), ColorPrintf(COLOR_DEFAULT, " %*s", 13, rate.c_str());
result.report_label.c_str()); }
if (!items.empty()) {
ColorPrintf(COLOR_DEFAULT, " %*s", 18, items.c_str());
}
if (!result.report_label.empty()) {
ColorPrintf(COLOR_DEFAULT, " %s", result.report_label.c_str());
}
ColorPrintf(COLOR_DEFAULT, "\n");
} }
} // end namespace benchmark } // end namespace benchmark
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment