summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/system/benchmarks/tscp.cpp
blob: 067584a3198c8138295930afb9c7c44c8159921b (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
#include <benchmark/benchmark.h>

#include <library/cpp/yt/system/tscp.h>

namespace NYT::NProfiling {
namespace {

////////////////////////////////////////////////////////////////////////////////

// Timestamp counter and processor id via a single serializing rdtscp.
void BM_TscpGet(benchmark::State& state)
{
    for (auto _ : state) {
        benchmark::DoNotOptimize(TTscp::Get());
    }
}
BENCHMARK(BM_TscpGet);

// Cheaper, lower-precision counterpart: rseq fast path + non-serializing rdtsc.
void BM_TscpGetApproximate(benchmark::State& state)
{
    for (auto _ : state) {
        benchmark::DoNotOptimize(TTscp::GetApproximate());
    }
}
BENCHMARK(BM_TscpGetApproximate);

////////////////////////////////////////////////////////////////////////////////

} // namespace
} // namespace NYT::NProfiling