From 1295ce8f23717d910caf602ee4458212e9a3e746 Mon Sep 17 00:00:00 2001 From: vladoovt <vlado@indicalab.com> Date: Thu, 27 Apr 2017 09:56:43 -0600 Subject: [PATCH] Fixes #378 coercion to double was causing counter to forget its flags, changed it so that its value is updated directly --- src/console_reporter.cc | 8 +++++++- src/counter.cc | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/console_reporter.cc b/src/console_reporter.cc index 3f3de029..6e2a9c6f 100644 --- a/src/console_reporter.cc +++ b/src/console_reporter.cc @@ -134,7 +134,13 @@ void ConsoleReporter::PrintRunData(const Run& result) { for (auto& c : result.counters) { auto const& s = HumanReadableNumber(c.second.value); - printer(Out, COLOR_DEFAULT, " %s=%s", c.first.c_str(), s.c_str()); + if (c.second.flags & Counter::Flags::kIsRate) { + std::string counter_rate = StrCat(" ", HumanReadableNumber(c.second.value), " ", c.first.c_str(), "/s"); + printer(Out, COLOR_DEFAULT, " %*s", 13, counter_rate.c_str()); + } + else { + printer(Out, COLOR_DEFAULT, " %s=%s", c.first.c_str(), s.c_str()); + } } if (!rate.empty()) { diff --git a/src/counter.cc b/src/counter.cc index 307863d3..2e9d918b 100644 --- a/src/counter.cc +++ b/src/counter.cc @@ -30,7 +30,7 @@ double Finish(Counter const& c, double cpu_time, double num_threads) { void Finish(UserCounters *l, double cpu_time, double num_threads) { for (auto &c : *l) { - c.second = Finish(c.second, cpu_time, num_threads); + c.second.value = Finish(c.second, cpu_time, num_threads); } } @@ -39,7 +39,7 @@ void Increment(UserCounters *l, UserCounters const& r) { for (auto &c : *l) { auto it = r.find(c.first); if (it != r.end()) { - c.second = c.second + it->second; + c.second.value = c.second + it->second; } } // add counters present in r, but not in *l