summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/benchmark/src/console_reporter.cc
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/benchmark/src/console_reporter.cc')
-rw-r--r--3rdparty/benchmark/src/console_reporter.cc42
1 files changed, 31 insertions, 11 deletions
diff --git a/3rdparty/benchmark/src/console_reporter.cc b/3rdparty/benchmark/src/console_reporter.cc
index 092936d5935..56bd3ced05b 100644
--- a/3rdparty/benchmark/src/console_reporter.cc
+++ b/3rdparty/benchmark/src/console_reporter.cc
@@ -18,6 +18,7 @@
#include <cstdio>
#include <iostream>
#include <string>
+#include <tuple>
#include <vector>
#include "check.h"
@@ -46,9 +47,9 @@ bool ConsoleReporter::ReportContext(const Context& context) {
"affected.\n";
#endif
- int output_width = fprintf(stdout, "%-*s %10s %10s %10s\n",
+ int output_width = fprintf(stdout, "%-*s %13s %13s %10s\n",
static_cast<int>(name_field_width_), "Benchmark",
- "Time(ns)", "CPU(ns)", "Iterations");
+ "Time", "CPU", "Iterations");
std::cout << std::string(output_width - 1, '-') << "\n";
return true;
@@ -92,25 +93,44 @@ void ConsoleReporter::PrintRunData(const Run& result) {
" items/s");
}
- double const multiplier = 1e9; // nano second multiplier
+ double multiplier;
+ const char* timeLabel;
+ std::tie(timeLabel, multiplier) = GetTimeUnitAndMultiplier(result.time_unit);
+
ColorPrintf(COLOR_GREEN, "%-*s ",
name_field_width_, result.benchmark_name.c_str());
+
if (result.iterations == 0) {
- ColorPrintf(COLOR_YELLOW, "%10.0f %10.0f ",
+ ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ",
result.real_accumulated_time * multiplier,
- result.cpu_accumulated_time * multiplier);
+ timeLabel,
+ result.cpu_accumulated_time * multiplier,
+ timeLabel);
} else {
- ColorPrintf(COLOR_YELLOW, "%10.0f %10.0f ",
+ ColorPrintf(COLOR_YELLOW, "%10.0f %s %10.0f %s ",
(result.real_accumulated_time * multiplier) /
(static_cast<double>(result.iterations)),
+ timeLabel,
(result.cpu_accumulated_time * multiplier) /
- (static_cast<double>(result.iterations)));
+ (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