aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2016-10-07 22:26:01 -0600
committerEric Fiselier <eric@efcs.ca>2016-10-07 22:26:01 -0600
commit36a251ab3ee4e6dc668129e0ef5fa62b1b8d5d49 (patch)
tree52484b8d93c2b34df5e6f094bf2ba09e2c5fa137
parent2555035f44d82160e51261c3add92cc38af352a7 (diff)
downloadgoogle-benchmark-36a251ab3ee4e6dc668129e0ef5fa62b1b8d5d49.tar.gz
Fix #300. Emit RMS as a float not a percentage in JSON
-rw-r--r--src/json_reporter.cc6
-rw-r--r--test/complexity_test.cc2
2 files changed, 6 insertions, 2 deletions
diff --git a/src/json_reporter.cc b/src/json_reporter.cc
index 8eaef07..cea5f9b 100644
--- a/src/json_reporter.cc
+++ b/src/json_reporter.cc
@@ -47,6 +47,10 @@ std::string FormatKV(std::string const& key, int64_t value) {
return ss.str();
}
+std::string FormatKV(std::string const& key, double value) {
+ return StringPrintF("\"%s\": %.2f", key.c_str(), value);
+}
+
int64_t RoundDouble(double v) { return static_cast<int64_t>(v + 0.5); }
} // end namespace
@@ -138,7 +142,7 @@ void JSONReporter::PrintRunData(Run const& run) {
out << indent << FormatKV("time_unit", GetTimeUnitString(run.time_unit));
} else if (run.report_rms) {
out << indent
- << FormatKV("rms", RoundDouble(run.GetAdjustedCPUTime() * 100)) << '%';
+ << FormatKV("rms", run.GetAdjustedCPUTime());
}
if (run.bytes_per_second > 0.0) {
out << ",\n"
diff --git a/test/complexity_test.cc b/test/complexity_test.cc
index 7a04891..14e03b0 100644
--- a/test/complexity_test.cc
+++ b/test/complexity_test.cc
@@ -31,7 +31,7 @@ int AddComplexityTest(std::string big_o_test_name, std::string rms_test_name,
{"\"time_unit\": \"ns\"$", MR_Next},
{"}", MR_Next},
{"\"name\": \"%rms_name\",$"},
- {"\"rms\": [0-9]+%$", MR_Next},
+ {"\"rms\": %float$", MR_Next},
{"}", MR_Next}});
AddCases(TC_CSVOut, {{"^\"%bigo_name\",,%float,%float,%bigo,,,,,$"},
{"^\"%bigo_name\"", MR_Not},