diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2019-03-14 03:01:24 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-03-14 03:01:24 +0000 |
commit | b3884a1d0147530c6348bda5af10be0a1e83c875 (patch) | |
tree | 846476297511da6a2ae04ac37a5fdc58d8c02cad | |
parent | bd45abed2f9bfe86afb6b679b7e6f69ba6b44816 (diff) | |
parent | 91c277079ad177b9ce43a45e8848560d9c8570cd (diff) | |
download | google-benchmark-android10-tests-release.tar.gz |
Snap for 5374457 from 91c277079ad177b9ce43a45e8848560d9c8570cd to qt-releaseandroid-vts-10.0_r9android-vts-10.0_r8android-vts-10.0_r7android-vts-10.0_r6android-vts-10.0_r5android-vts-10.0_r4android-vts-10.0_r3android-vts-10.0_r2android-vts-10.0_r16android-vts-10.0_r15android-vts-10.0_r14android-vts-10.0_r13android-vts-10.0_r12android-vts-10.0_r11android-vts-10.0_r10android-vts-10.0_r1android-security-10.0.0_r75android-security-10.0.0_r74android-security-10.0.0_r73android-security-10.0.0_r72android-security-10.0.0_r71android-security-10.0.0_r70android-security-10.0.0_r69android-security-10.0.0_r68android-security-10.0.0_r67android-security-10.0.0_r66android-security-10.0.0_r65android-security-10.0.0_r64android-security-10.0.0_r63android-security-10.0.0_r62android-security-10.0.0_r61android-security-10.0.0_r60android-security-10.0.0_r59android-security-10.0.0_r58android-security-10.0.0_r57android-security-10.0.0_r56android-security-10.0.0_r55android-security-10.0.0_r54android-security-10.0.0_r53android-security-10.0.0_r52android-security-10.0.0_r51android-security-10.0.0_r50android-security-10.0.0_r49android-security-10.0.0_r48android-mainline-10.0.0_r3android-mainline-10.0.0_r2android-mainline-10.0.0_r1android-cts-10.0_r9android-cts-10.0_r8android-cts-10.0_r7android-cts-10.0_r6android-cts-10.0_r5android-cts-10.0_r4android-cts-10.0_r3android-cts-10.0_r2android-cts-10.0_r16android-cts-10.0_r15android-cts-10.0_r14android-cts-10.0_r13android-cts-10.0_r12android-cts-10.0_r11android-cts-10.0_r10android-cts-10.0_r1android-10.0.0_r6android-10.0.0_r5android-10.0.0_r47android-10.0.0_r46android-10.0.0_r4android-10.0.0_r3android-10.0.0_r2android-10.0.0_r17android-10.0.0_r11android-10.0.0_r10android-10.0.0_r1android10-tests-releaseandroid10-security-releaseandroid10-s3-releaseandroid10-s2-releaseandroid10-s1-releaseandroid10-releaseandroid10-mainline-releaseandroid10-mainline-a-release
Change-Id: I4f667b20c0bec35e99dacd9e945e7ba110b6eed3
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | METADATA | 6 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | src/internal_macros.h | 2 | ||||
-rw-r--r-- | src/sysinfo.cc | 49 |
5 files changed, 67 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 76e5fc5..d7ed57e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -183,6 +183,10 @@ else() add_definitions(-D_GNU_SOURCE=1) endif() + if (QNXNTO) + add_definitions(-D_QNX_SOURCE) + endif() + # Link time optimisation if (BENCHMARK_ENABLE_LTO) add_cxx_compiler_flag(-flto) @@ -251,6 +255,7 @@ if (NOT BENCHMARK_ENABLE_EXCEPTIONS AND HAVE_STD_REGEX endif() cxx_feature_check(STEADY_CLOCK) # Ensure we have pthreads +set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) # Set up directories @@ -9,10 +9,10 @@ third_party { type: GIT value: "https://github.com/google/benchmark.git" } - version: "97393e5ef820fda0330830d56c774949b4cfbb29" + version: "d205ead299c7cddd5e1bc3478d57ad4320a4a53c" last_upgrade_date { year: 2019 - month: 2 - day: 1 + month: 3 + day: 4 } } @@ -615,7 +615,14 @@ creating/registering the tests using the following macros: For Example: ```c++ -class MyFixture : public benchmark::Fixture {}; +class MyFixture : public benchmark::Fixture { +public: + void SetUp(const ::benchmark::State& state) { + } + + void TearDown(const ::benchmark::State& state) { + } +}; BENCHMARK_F(MyFixture, FooTest)(benchmark::State& st) { for (auto _ : st) { diff --git a/src/internal_macros.h b/src/internal_macros.h index 5dbf4fd..6adf00d 100644 --- a/src/internal_macros.h +++ b/src/internal_macros.h @@ -70,6 +70,8 @@ #define BENCHMARK_OS_FUCHSIA 1 #elif defined (__SVR4) && defined (__sun) #define BENCHMARK_OS_SOLARIS 1 +#elif defined(__QNX__) +#define BENCHMARK_OS_QNX 1 #endif #if defined(__ANDROID__) && defined(__GLIBCXX__) diff --git a/src/sysinfo.cc b/src/sysinfo.cc index c0c07e5..953c170 100644 --- a/src/sysinfo.cc +++ b/src/sysinfo.cc @@ -37,6 +37,9 @@ #if defined(BENCHMARK_OS_SOLARIS) #include <kstat.h> #endif +#if defined(BENCHMARK_OS_QNX) +#include <sys/syspage.h> +#endif #include <algorithm> #include <array> @@ -209,6 +212,9 @@ bool ReadFromFile(std::string const& fname, ArgT* arg) { bool CpuScalingEnabled(int num_cpus) { // We don't have a valid CPU count, so don't even bother. if (num_cpus <= 0) return false; +#ifdef BENCHMARK_OS_QNX + return false; +#endif #ifndef BENCHMARK_OS_WINDOWS // On Linux, the CPUfreq subsystem exposes CPU information as files on the // local file system. If reading the exported files fails, then we may not be @@ -356,6 +362,40 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizesWindows() { } return res; } +#elif BENCHMARK_OS_QNX +std::vector<CPUInfo::CacheInfo> GetCacheSizesQNX() { + std::vector<CPUInfo::CacheInfo> res; + struct cacheattr_entry *cache = SYSPAGE_ENTRY(cacheattr); + uint32_t const elsize = SYSPAGE_ELEMENT_SIZE(cacheattr); + int num = SYSPAGE_ENTRY_SIZE(cacheattr) / elsize ; + for(int i = 0; i < num; ++i ) { + CPUInfo::CacheInfo info; + switch (cache->flags){ + case CACHE_FLAG_INSTR : + info.type = "Instruction"; + info.level = 1; + break; + case CACHE_FLAG_DATA : + info.type = "Data"; + info.level = 1; + break; + case CACHE_FLAG_UNIFIED : + info.type = "Unified"; + info.level = 2; + case CACHE_FLAG_SHARED : + info.type = "Shared"; + info.level = 3; + default : + continue; + break; + } + info.size = cache->line_size * cache->num_lines; + info.num_sharing = 0; + res.push_back(std::move(info)); + cache = SYSPAGE_ARRAY_ADJ_OFFSET(cacheattr, cache, elsize); + } + return res; +} #endif std::vector<CPUInfo::CacheInfo> GetCacheSizes() { @@ -363,6 +403,8 @@ std::vector<CPUInfo::CacheInfo> GetCacheSizes() { return GetCacheSizesMacOSX(); #elif defined(BENCHMARK_OS_WINDOWS) return GetCacheSizesWindows(); +#elif defined(BENCHMARK_OS_QNX) + return GetCacheSizesQNX(); #else return GetCacheSizesFromKVFS(); #endif @@ -389,6 +431,8 @@ std::string GetSystemName() { #else // defined(BENCHMARK_OS_WINDOWS) #ifdef BENCHMARK_OS_MACOSX //Mac Doesnt have HOST_NAME_MAX defined #define HOST_NAME_MAX 64 +#elif defined(BENCHMARK_OS_QNX) +#define HOST_NAME_MAX 154 #endif char hostname[HOST_NAME_MAX]; int retVal = gethostname(hostname, HOST_NAME_MAX); @@ -421,6 +465,8 @@ int GetNumCPUs() { strerror(errno)); } return NumCPU; +#elif defined(BENCHMARK_OS_QNX) + return static_cast<int>(_syspage_ptr->num_cpu); #else int NumCPUs = 0; int MaxID = -1; @@ -600,6 +646,9 @@ double GetCPUCyclesPerSecond() { double clock_hz = knp->value.ui64; kstat_close(kc); return clock_hz; +#elif defined (BENCHMARK_OS_QNX) + return static_cast<double>((int64_t)(SYSPAGE_ENTRY(cpuinfo)->speed) * + (int64_t)(1000 * 1000)); #endif // If we've fallen through, attempt to roughly estimate the CPU clock rate. const int estimate_time_ms = 1000; |