diff options
Diffstat (limited to '')
| -rw-r--r-- | bench/benchmark.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/bench/benchmark.h b/bench/benchmark.h index 92f9809..63ca1ff 100644 --- a/bench/benchmark.h +++ b/bench/benchmark.h @@ -3,6 +3,7 @@ # include <sched.h> #endif +#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -21,6 +22,10 @@ # define LIBRARY_SUFFIX "" #endif +#ifndef USE_CPU +# define USE_CPU 0 +#endif + #ifndef CLOCK_MONOTONIC_RAW # define CLOCK_MONOTONIC_RAW CLOCK_MONOTONIC @@ -122,12 +127,14 @@ benchmark_init(void) FILE *f; char *line = 0; size_t size = 0; + char path[PATH_MAX]; # endif CPU_ZERO(&cpuset); - CPU_SET(0, &cpuset); + CPU_SET(USE_CPU, &cpuset); sched_setaffinity(getpid(), sizeof(cpuset), &cpuset); # if defined(USE_RDTSC) - f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", "r"); + sprintf(path, "/sys/devices/system/cpu/cpu%i/cpufreq/cpuinfo_max_freq", USE_CPU); + f = fopen(path, "r"); if (getline(&line, &size, f) < 0) abort(); fclose(f); |
