benchmark.cpp 1021 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "benchmark/benchmark.h"
  2. #include <benchmark/benchmark.h>
  3. #include <library/cpp/yt/cpu_clock/clock.h>
  4. namespace NYT {
  5. namespace {
  6. ////////////////////////////////////////////////////////////////////////////////
  7. void BM_GetCpuInstant(benchmark::State& state)
  8. {
  9. for (auto _ : state) {
  10. benchmark::DoNotOptimize(GetCpuInstant());
  11. }
  12. }
  13. BENCHMARK(BM_GetCpuInstant);
  14. void BM_GetCpuApproximateInstant(benchmark::State& state)
  15. {
  16. for (auto _ : state) {
  17. benchmark::DoNotOptimize(GetApproximateCpuInstant());
  18. }
  19. }
  20. BENCHMARK(BM_GetCpuApproximateInstant);
  21. void BM_GetInstant(benchmark::State& state)
  22. {
  23. for (auto _ : state) {
  24. benchmark::DoNotOptimize(GetInstant());
  25. }
  26. }
  27. BENCHMARK(BM_GetInstant);
  28. void BM_InstantNow(benchmark::State& state)
  29. {
  30. for (auto _ : state) {
  31. benchmark::DoNotOptimize(TInstant::Now());
  32. }
  33. }
  34. BENCHMARK(BM_InstantNow);
  35. ////////////////////////////////////////////////////////////////////////////////
  36. } // namespace
  37. } // namespace NYT