summaryrefslogtreecommitdiffstats
path: root/src/jaegertracing/opentelemetry-cpp/sdk/test/common/random_benchmark.cc
blob: df2ebf95ec07d12531f8b81dc6416bbbb9f64749 (plain)
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
34
35
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

#include "src/common/random.h"

#include <cstdint>
#include <random>

#include <benchmark/benchmark.h>

namespace
{
using opentelemetry::sdk::common::Random;

void BM_RandomIdGeneration(benchmark::State &state)
{
  while (state.KeepRunning())
  {
    benchmark::DoNotOptimize(Random::GenerateRandom64());
  }
}
BENCHMARK(BM_RandomIdGeneration);

void BM_RandomIdStdGeneration(benchmark::State &state)
{
  std::mt19937_64 generator{0};
  while (state.KeepRunning())
  {
    benchmark::DoNotOptimize(generator());
  }
}
BENCHMARK(BM_RandomIdStdGeneration);

}  // namespace
BENCHMARK_MAIN();