Skip to content

Commit 2864e25

Browse files
committed
Update Tests for uniform_int_distribution
1 parent 0894094 commit 2864e25

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// UNSUPPORTED: c++03
10+
11+
#include <cstdint>
12+
#include <random>
13+
14+
#include <benchmark/benchmark.h>
15+
16+
template <typename Eng, std::uint64_t Max>
17+
static void bm_uniform_int_distribution(benchmark::State& state) {
18+
Eng eng;
19+
std::uniform_int_distribution<std::uint64_t> dist(1ull, Max);
20+
for (auto _ : state) {
21+
benchmark::DoNotOptimize(dist(eng));
22+
}
23+
}
24+
25+
// n = 1
26+
BENCHMARK(bm_uniform_int_distribution<std::minstd_rand0, 1ull << 20>);
27+
BENCHMARK(bm_uniform_int_distribution<std::ranlux24_base, 1ull << 20>);
28+
29+
// n = 2, n0 = 2
30+
BENCHMARK(bm_uniform_int_distribution<std::minstd_rand0, 1ull << 40>);
31+
BENCHMARK(bm_uniform_int_distribution<std::ranlux24_base, 1ull << 40>);
32+
33+
// n = 2, n0 = 1
34+
BENCHMARK(bm_uniform_int_distribution<std::minstd_rand0, 1ull << 41>);
35+
BENCHMARK(bm_uniform_int_distribution<std::ranlux24_base, 1ull << 41>);
36+
37+
BENCHMARK_MAIN();

0 commit comments

Comments
 (0)