aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2020-08-11 04:29:33 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2020-08-11 04:29:33 +0000
commitf61124a0b60d3be9017d9d38ce31d91e773e6ccf (patch)
tree712ac715f87c97473756a3c52e7491e9567469c6
parentf473c44bc4203f970d56406a8122e53851b09fac (diff)
parent31cbeeb6792fcac8f9996ba37277bf95399b5e99 (diff)
downloadgoogle-benchmark-f61124a0b60d3be9017d9d38ce31d91e773e6ccf.tar.gz
Upgrade google-benchmark to 1302d2ce094a9753b0f81a81ea74c0fa71fae582 am: ee5323428d am: 4e25a86e8b am: 4240a052d0 am: 31cbeeb679
Original change: https://android-review.googlesource.com/c/platform/external/google-benchmark/+/1395728 Change-Id: I367ffb8f5fbcd642833991249f420e17115aabae
-rw-r--r--METADATA4
-rw-r--r--include/benchmark/benchmark.h9
-rw-r--r--src/json_reporter.cc6
-rw-r--r--src/reporter.cc2
-rw-r--r--src/sysinfo.cc16
-rw-r--r--test/reporter_output_test.cc3
6 files changed, 26 insertions, 14 deletions
diff --git a/METADATA b/METADATA
index 9b8648f..75ceba4 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@ third_party {
type: GIT
value: "https://github.com/google/benchmark.git"
}
- version: "37177a84b7e8d33696ea1e1854513cb0de3b4dc3"
+ version: "1302d2ce094a9753b0f81a81ea74c0fa71fae582"
license_type: NOTICE
last_upgrade_date {
year: 2020
- month: 7
+ month: 8
day: 10
}
}
diff --git a/include/benchmark/benchmark.h b/include/benchmark/benchmark.h
index e5f6778..da638f9 100644
--- a/include/benchmark/benchmark.h
+++ b/include/benchmark/benchmark.h
@@ -176,6 +176,7 @@ BENCHMARK(BM_test)->Unit(benchmark::kMillisecond);
#include <map>
#include <set>
#include <string>
+#include <utility>
#include <vector>
#if defined(BENCHMARK_HAS_CXX11)
@@ -1294,10 +1295,16 @@ struct CPUInfo {
int num_sharing;
};
+ enum Scaling {
+ UNKNOWN,
+ ENABLED,
+ DISABLED
+ };
+
int num_cpus;
double cycles_per_second;
std::vector<CacheInfo> caches;
- bool scaling_enabled;
+ Scaling scaling;
std::vector<double> load_avg;
static const CPUInfo& Get();
diff --git a/src/json_reporter.cc b/src/json_reporter.cc
index e5f3c35..959d245 100644
--- a/src/json_reporter.cc
+++ b/src/json_reporter.cc
@@ -122,8 +122,10 @@ bool JSONReporter::ReportContext(const Context& context) {
<< FormatKV("mhz_per_cpu",
RoundDouble(info.cycles_per_second / 1000000.0))
<< ",\n";
- out << indent << FormatKV("cpu_scaling_enabled", info.scaling_enabled)
- << ",\n";
+ if (CPUInfo::Scaling::UNKNOWN != info.scaling) {
+ out << indent << FormatKV("cpu_scaling_enabled", info.scaling == CPUInfo::Scaling::ENABLED ? true : false)
+ << ",\n";
+ }
out << indent << "\"caches\": [\n";
indent = std::string(6, ' ');
diff --git a/src/reporter.cc b/src/reporter.cc
index 0b54fa4..337575a 100644
--- a/src/reporter.cc
+++ b/src/reporter.cc
@@ -64,7 +64,7 @@ void BenchmarkReporter::PrintBasicContext(std::ostream *out,
Out << "\n";
}
- if (info.scaling_enabled) {
+ if (CPUInfo::Scaling::ENABLED == info.scaling) {
Out << "***WARNING*** CPU scaling is enabled, the benchmark "
"real time measurements may be noisy and will incur extra "
"overhead.\n";
diff --git a/src/sysinfo.cc b/src/sysinfo.cc
index 5b7c4af..8bab932 100644
--- a/src/sysinfo.cc
+++ b/src/sysinfo.cc
@@ -57,6 +57,7 @@
#include <memory>
#include <sstream>
#include <locale>
+#include <utility>
#include "check.h"
#include "cycleclock.h"
@@ -209,11 +210,11 @@ bool ReadFromFile(std::string const& fname, ArgT* arg) {
return f.good();
}
-bool CpuScalingEnabled(int num_cpus) {
+CPUInfo::Scaling CpuScaling(int num_cpus) {
// We don't have a valid CPU count, so don't even bother.
- if (num_cpus <= 0) return false;
+ if (num_cpus <= 0) return CPUInfo::Scaling::UNKNOWN;
#ifdef BENCHMARK_OS_QNX
- return false;
+ return CPUInfo::Scaling::UNKNOWN;
#endif
#ifndef BENCHMARK_OS_WINDOWS
// On Linux, the CPUfreq subsystem exposes CPU information as files on the
@@ -223,10 +224,11 @@ bool CpuScalingEnabled(int num_cpus) {
for (int cpu = 0; cpu < num_cpus; ++cpu) {
std::string governor_file =
StrCat("/sys/devices/system/cpu/cpu", cpu, "/cpufreq/scaling_governor");
- if (ReadFromFile(governor_file, &res) && res != "performance") return true;
+ if (ReadFromFile(governor_file, &res) && res != "performance") return CPUInfo::Scaling::ENABLED;
}
+ return CPUInfo::Scaling::DISABLED;
#endif
- return false;
+ return CPUInfo::Scaling::UNKNOWN;
}
int CountSetBitsInCPUMap(std::string Val) {
@@ -382,9 +384,11 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizesQNX() {
case CACHE_FLAG_UNIFIED :
info.type = "Unified";
info.level = 2;
+ break;
case CACHE_FLAG_SHARED :
info.type = "Shared";
info.level = 3;
+ break;
default :
continue;
break;
@@ -695,7 +699,7 @@ CPUInfo::CPUInfo()
: num_cpus(GetNumCPUs()),
cycles_per_second(GetCPUCyclesPerSecond()),
caches(GetCacheSizes()),
- scaling_enabled(CpuScalingEnabled(num_cpus)),
+ scaling(CpuScaling(num_cpus)),
load_avg(GetLoadAvg()) {}
diff --git a/test/reporter_output_test.cc b/test/reporter_output_test.cc
index d806a4e..bcce007 100644
--- a/test/reporter_output_test.cc
+++ b/test/reporter_output_test.cc
@@ -28,8 +28,7 @@ static int AddContextCases() {
MR_Next},
{"\"num_cpus\": %int,$", MR_Next},
{"\"mhz_per_cpu\": %float,$", MR_Next},
- {"\"cpu_scaling_enabled\": ", MR_Next},
- {"\"caches\": \\[$", MR_Next}});
+ {"\"caches\": \\[$", MR_Default}});
auto const& Info = benchmark::CPUInfo::Get();
auto const& Caches = Info.caches;
if (!Caches.empty()) {