blob: 2bb36eb4657ad3057fe6c380e811a49fe089840d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <library/cpp/yt/system/cpu_id.h>
#include <benchmark/benchmark.h>
#include <sched.h>
namespace NYT {
namespace {
////////////////////////////////////////////////////////////////////////////////
// rseq: a single thread-local read.
void BM_GetCurrentCpuId(benchmark::State& state)
{
for (auto _ : state) {
benchmark::DoNotOptimize(GetCurrentCpuId());
}
}
BENCHMARK(BM_GetCurrentCpuId);
// The fallback path: sched_getcpu() (vDSO getcpu).
void BM_SchedGetCpu(benchmark::State& state)
{
for (auto _ : state) {
benchmark::DoNotOptimize(sched_getcpu());
}
}
BENCHMARK(BM_SchedGetCpu);
////////////////////////////////////////////////////////////////////////////////
} // namespace
} // namespace NYT
|