7 #if defined(__i386__) || defined(__x86_64__) 15 #elif defined(__linux__) 18 #include <sys/syscall.h> 19 #include <linux/perf_event.h> 22 static struct perf_event_attr attr;
26 attr.type = PERF_TYPE_HARDWARE;
27 attr.config = PERF_COUNT_HW_CPU_CYCLES;
28 fd = syscall(__NR_perf_event_open, &attr, 0, -1, -1, 0);
41 if (
fd == -1 ||
read(
fd, &result,
sizeof(result)) < (ssize_t)
sizeof(result)) {
bool read(const std::string &s, Value &value)
uint64_t perf_cpucycles(void)
Functions for measurement of CPU cycles.