mirror of https://github.com/google/benchmark.git
Merge pull request #201 from google/200
Only output optional fields if they're set
This commit is contained in:
commit
277e7aafe6
|
@ -64,9 +64,9 @@ DEFINE_int32(benchmark_repetitions, 1,
|
|||
"The number of runs of each benchmark. If greater than 1, the "
|
||||
"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 "
|
||||
"'tabular', 'json', or 'csv'.");
|
||||
"'console', 'json', or 'csv'.");
|
||||
|
||||
DEFINE_bool(color_print, true, "Enables colorized logging.");
|
||||
|
||||
|
@ -828,7 +828,7 @@ void RunMatchingBenchmarks(const std::string& spec,
|
|||
|
||||
std::unique_ptr<BenchmarkReporter> GetDefaultReporter() {
|
||||
typedef std::unique_ptr<BenchmarkReporter> PtrType;
|
||||
if (FLAGS_benchmark_format == "tabular") {
|
||||
if (FLAGS_benchmark_format == "console") {
|
||||
return PtrType(new ConsoleReporter);
|
||||
} else if (FLAGS_benchmark_format == "json") {
|
||||
return PtrType(new JSONReporter);
|
||||
|
@ -874,7 +874,7 @@ void PrintUsageAndExit() {
|
|||
" [--benchmark_filter=<regex>]\n"
|
||||
" [--benchmark_min_time=<min_time>]\n"
|
||||
" [--benchmark_repetitions=<num_repetitions>]\n"
|
||||
" [--benchmark_format=<tabular|json|csv>]\n"
|
||||
" [--benchmark_format=<console|json|csv>]\n"
|
||||
" [--color_print={true|false}]\n"
|
||||
" [--v=<verbosity>]\n");
|
||||
exit(0);
|
||||
|
@ -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 != "csv") {
|
||||
PrintUsageAndExit();
|
||||
|
|
|
@ -99,6 +99,7 @@ void ConsoleReporter::PrintRunData(const Run& result) {
|
|||
|
||||
ColorPrintf(COLOR_GREEN, "%-*s ",
|
||||
name_field_width_, result.benchmark_name.c_str());
|
||||
|
||||
if (result.iterations == 0) {
|
||||
ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ",
|
||||
result.real_accumulated_time * multiplier,
|
||||
|
@ -114,11 +115,22 @@ void ConsoleReporter::PrintRunData(const Run& result) {
|
|||
(static_cast<double>(result.iterations)),
|
||||
timeLabel);
|
||||
}
|
||||
|
||||
ColorPrintf(COLOR_CYAN, "%10lld", result.iterations);
|
||||
ColorPrintf(COLOR_DEFAULT, "%*s %*s %s\n",
|
||||
13, rate.c_str(),
|
||||
18, items.c_str(),
|
||||
result.report_label.c_str());
|
||||
|
||||
if (!rate.empty()) {
|
||||
ColorPrintf(COLOR_DEFAULT, " %*s", 13, rate.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
|
||||
|
|
Loading…
Reference in New Issue