mirror of
https://github.com/google/benchmark.git
synced 2024-12-27 13:00:36 +08:00
3b19d7222d
* Fix CPU frequency estimation on riscv * Cleanup code for CPU frequency estimation * Fix use before definition of the macro * Move the platform definitions back * Fix compilation error on windows * Remove unused sleep.h and sleep.cc
17 lines
389 B
C++
17 lines
389 B
C++
#include <pthread.h>
|
|
int main() {
|
|
cpu_set_t set;
|
|
CPU_ZERO(&set);
|
|
for (int i = 0; i < CPU_SETSIZE; ++i) {
|
|
CPU_SET(i, &set);
|
|
CPU_CLR(i, &set);
|
|
}
|
|
pthread_t self = pthread_self();
|
|
int ret;
|
|
ret = pthread_getaffinity_np(self, sizeof(set), &set);
|
|
if (ret != 0) return ret;
|
|
ret = pthread_setaffinity_np(self, sizeof(set), &set);
|
|
if (ret != 0) return ret;
|
|
return 0;
|
|
}
|