Marat Dukhan | 8127f77 | 2017-11-10 21:02:28 +0000 | [diff] [blame] | 1 | #include <benchmark/benchmark.h> |
| 2 | |
| 3 | #include <cpuinfo.h> |
| 4 | |
| 5 | |
| 6 | static void cpuinfo_get_current_processor(benchmark::State& state) { |
| 7 | cpuinfo_initialize(); |
| 8 | while (state.KeepRunning()) { |
| 9 | const cpuinfo_processor* current_processor = cpuinfo_get_current_processor(); |
| 10 | benchmark::DoNotOptimize(current_processor); |
| 11 | } |
| 12 | } |
Marat Dukhan | aeba38b | 2017-12-18 17:46:17 -0800 | [diff] [blame] | 13 | BENCHMARK(cpuinfo_get_current_processor)->Unit(benchmark::kNanosecond); |
Marat Dukhan | 8127f77 | 2017-11-10 21:02:28 +0000 | [diff] [blame] | 14 | |
| 15 | static void cpuinfo_get_current_core(benchmark::State& state) { |
| 16 | cpuinfo_initialize(); |
| 17 | while (state.KeepRunning()) { |
| 18 | const cpuinfo_core* current_core = cpuinfo_get_current_core(); |
| 19 | benchmark::DoNotOptimize(current_core); |
| 20 | } |
| 21 | } |
Marat Dukhan | aeba38b | 2017-12-18 17:46:17 -0800 | [diff] [blame] | 22 | BENCHMARK(cpuinfo_get_current_core)->Unit(benchmark::kNanosecond); |
Marat Dukhan | 8127f77 | 2017-11-10 21:02:28 +0000 | [diff] [blame] | 23 | |
| 24 | BENCHMARK_MAIN(); |