24 #include "benchmark/benchmark.h"
43 #ifdef BENCHMARK_OS_WINDOWS
46 <<
"Color printing is only supported for stdout on windows."
47 " Disabling color printing\n";
57 "Benchmark",
"Time",
"CPU",
"Iterations");
58 if(!
run.counters.empty()) {
60 for(
auto const& c :
run.counters) {
64 str +=
" UserCounters...";
72 for (
const auto&
run : reports) {
116 typedef void(PrinterFn)(std::ostream&,
LogColor,
const char*, ...);
123 result.benchmark_name().c_str());
125 if (
result.error_occurred) {
126 printer(Out,
COLOR_RED,
"ERROR OCCURRED: \'%s\'",
127 result.error_message.c_str());
132 const double real_time =
result.GetAdjustedRealTime();
133 const double cpu_time =
result.GetAdjustedCPUTime();
138 if (
result.report_big_o) {
140 printer(Out,
COLOR_YELLOW,
"%10.2f %-4s %10.2f %-4s ", real_time, big_o.c_str(),
141 cpu_time, big_o.c_str());
142 }
else if (
result.report_rms) {
143 printer(Out,
COLOR_YELLOW,
"%10.0f %-4s %10.0f %-4s ", real_time * 100,
"%",
144 cpu_time * 100,
"%");
148 printer(Out,
COLOR_YELLOW,
"%s %-4s %s %-4s ", real_time_str.c_str(), timeLabel,
149 cpu_time_str.c_str(), timeLabel);
153 (100. *
result.real_accumulated_time),
"%",
154 (100. *
result.cpu_accumulated_time),
"%");
161 for (
auto& c :
result.counters) {
162 const std::size_t cNameLen =
std::max(std::string::size_type(10),
165 const char* unit =
"";
168 s =
StrFormat(
"%.2f", 100. * c.second.value);
176 printer(Out,
COLOR_DEFAULT,
" %*s%s", cNameLen - strlen(unit), s.c_str(),
179 printer(Out,
COLOR_DEFAULT,
" %s=%s%s", c.first.c_str(), s.c_str(), unit);
183 if (!
result.report_label.empty()) {