diff options
author | Haibo Huang <hhb@google.com> | 2020-08-11 03:45:21 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2020-08-11 03:45:21 +0000 |
commit | 4240a052d0e53149f3d94070940ff5bbaf482b1a (patch) | |
tree | 712ac715f87c97473756a3c52e7491e9567469c6 | |
parent | f6d69ef8c85a81c0d494fafa63ed9162f52d37ce (diff) | |
parent | 4e25a86e8b0872adff02d78af3d8cc1bbceaab32 (diff) | |
download | google-benchmark-4240a052d0e53149f3d94070940ff5bbaf482b1a.tar.gz |
Upgrade google-benchmark to 1302d2ce094a9753b0f81a81ea74c0fa71fae582 am: ee5323428d am: 4e25a86e8b
Original change: https://android-review.googlesource.com/c/platform/external/google-benchmark/+/1395728
Change-Id: I9eabcbab20ddb4012cd48978f0fd3fcba568e85a
-rw-r--r-- | METADATA | 4 | ||||
-rw-r--r-- | include/benchmark/benchmark.h | 9 | ||||
-rw-r--r-- | src/json_reporter.cc | 6 | ||||
-rw-r--r-- | src/reporter.cc | 2 | ||||
-rw-r--r-- | src/sysinfo.cc | 16 | ||||
-rw-r--r-- | test/reporter_output_test.cc | 3 |
6 files changed, 26 insertions, 14 deletions
@@ -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()) { |