aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaibo Huang <hhb@google.com>2019-03-13 13:37:05 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-03-13 13:37:05 -0700
commit91c277079ad177b9ce43a45e8848560d9c8570cd (patch)
tree846476297511da6a2ae04ac37a5fdc58d8c02cad
parent29542a0b1d5a43faa245cff9ade6093446535192 (diff)
parentd65c3f75f13fc531404f7e5695f67c976f955446 (diff)
downloadgoogle-benchmark-android10-qpr2-s1-release.tar.gz
am: d65c3f75f1 Change-Id: I54b47458021fa49fbb2174ceb8ba9dfd6d1de5b3
-rw-r--r--CMakeLists.txt5
-rw-r--r--METADATA6
-rw-r--r--README.md9
-rw-r--r--src/internal_macros.h2
-rw-r--r--src/sysinfo.cc49
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
diff --git a/METADATA b/METADATA
index 3aafafb..b0ac15d 100644
--- a/METADATA
+++ b/METADATA
@@ -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
}
}
diff --git a/README.md b/README.md
index 858ea23..902915e 100644
--- a/README.md
+++ b/README.md
@@ -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;