Commit 36711948 by Roman Lebedev Committed by Dominic Hamon

CPU caches are binary units, not SI. (#911)

As disscussed in https://github.com/google/benchmark/issues/899, it is all but certain that the multiplier should be 1024, not 1000. Fixes https://github.com/google/benchmark/issues/899
parent 318d0711
...@@ -49,7 +49,7 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out, ...@@ -49,7 +49,7 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out,
Out << "CPU Caches:\n"; Out << "CPU Caches:\n";
for (auto &CInfo : info.caches) { for (auto &CInfo : info.caches) {
Out << " L" << CInfo.level << " " << CInfo.type << " " Out << " L" << CInfo.level << " " << CInfo.type << " "
<< (CInfo.size / 1000) << "K"; << (CInfo.size / 1024) << " KiB";
if (CInfo.num_sharing != 0) if (CInfo.num_sharing != 0)
Out << " (x" << (info.num_cpus / CInfo.num_sharing) << ")"; Out << " (x" << (info.num_cpus / CInfo.num_sharing) << ")";
Out << "\n"; Out << "\n";
......
...@@ -270,7 +270,7 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizesFromKVFS() { ...@@ -270,7 +270,7 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizesFromKVFS() {
else if (f && suffix != "K") else if (f && suffix != "K")
PrintErrorAndDie("Invalid cache size format: Expected bytes ", suffix); PrintErrorAndDie("Invalid cache size format: Expected bytes ", suffix);
else if (suffix == "K") else if (suffix == "K")
info.size *= 1000; info.size *= 1024;
} }
if (!ReadFromFile(StrCat(FPath, "type"), &info.type)) if (!ReadFromFile(StrCat(FPath, "type"), &info.type))
PrintErrorAndDie("Failed to read from file ", FPath, "type"); PrintErrorAndDie("Failed to read from file ", FPath, "type");
......
...@@ -38,9 +38,9 @@ static int AddContextCases() { ...@@ -38,9 +38,9 @@ static int AddContextCases() {
for (size_t I = 0; I < Caches.size(); ++I) { for (size_t I = 0; I < Caches.size(); ++I) {
std::string num_caches_str = std::string num_caches_str =
Caches[I].num_sharing != 0 ? " \\(x%int\\)$" : "$"; Caches[I].num_sharing != 0 ? " \\(x%int\\)$" : "$";
AddCases( AddCases(TC_ConsoleErr,
TC_ConsoleErr, {{"L%int (Data|Instruction|Unified) %int KiB" + num_caches_str,
{{"L%int (Data|Instruction|Unified) %intK" + num_caches_str, MR_Next}}); MR_Next}});
AddCases(TC_JSONOut, {{"\\{$", MR_Next}, AddCases(TC_JSONOut, {{"\\{$", MR_Next},
{"\"type\": \"", MR_Next}, {"\"type\": \"", MR_Next},
{"\"level\": %int,$", MR_Next}, {"\"level\": %int,$", MR_Next},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment