Fix #300. Emit RMS as a float not a percentage in JSON
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 @@
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 @@
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 @@
{"\"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},