aboutsummaryrefslogblamecommitdiffstats
path: root/library/cpp/yt/cpu_clock/benchmark/benchmark.cpp
blob: 86c751a7bb38e33ea985cd7e4d3c4217209f38b4 (plain) (tree)


























                                                                                







                                               











                                                                                
#include "benchmark/benchmark.h"
#include <benchmark/benchmark.h>

#include <library/cpp/yt/cpu_clock/clock.h>

namespace NYT {
namespace {

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

void BM_GetCpuInstant(benchmark::State& state)
{
    for (auto _ : state) {
        benchmark::DoNotOptimize(GetCpuInstant());
    }
}

BENCHMARK(BM_GetCpuInstant);

void BM_GetCpuApproximateInstant(benchmark::State& state)
{
    for (auto _ : state) {
        benchmark::DoNotOptimize(GetApproximateCpuInstant());
    }
}

BENCHMARK(BM_GetCpuApproximateInstant);

void BM_GetInstant(benchmark::State& state)
{
    for (auto _ : state) {
        benchmark::DoNotOptimize(GetInstant());
    }
}

BENCHMARK(BM_GetInstant);

void BM_InstantNow(benchmark::State& state)
{
    for (auto _ : state) {
        benchmark::DoNotOptimize(TInstant::Now());
    }
}

BENCHMARK(BM_InstantNow);

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

} // namespace
} // namespace NYT