Skip to content

Commit c209e8a

Browse files
committed
Update Tests for uniform_int_distribution
1 parent 136f2ba commit c209e8a

File tree

2 files changed

+689
-0
lines changed

2 files changed

+689
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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 <benchmark/benchmark.h>
12+
#include <cstdint>
13+
#include <random>
14+
15+
template <typename Eng, std::uint64_t Max>
16+
static void bm_rand_uni_int(benchmark::State& state) {
17+
Eng eng;
18+
std::uniform_int_distribution<std::uint64_t> dist(1ull, Max);
19+
for (auto _ : state) {
20+
benchmark::DoNotOptimize(dist(eng));
21+
}
22+
}
23+
24+
// n = 1
25+
BENCHMARK(bm_rand_uni_int<std::minstd_rand0, 1ull << 20>);
26+
BENCHMARK(bm_rand_uni_int<std::ranlux24_base, 1ull << 20>);
27+
28+
// n = 2, n0 = 2
29+
BENCHMARK(bm_rand_uni_int<std::minstd_rand0, 1ull << 40>);
30+
BENCHMARK(bm_rand_uni_int<std::ranlux24_base, 1ull << 40>);
31+
32+
// n = 2, n0 = 1
33+
BENCHMARK(bm_rand_uni_int<std::minstd_rand0, 1ull << 41>);
34+
BENCHMARK(bm_rand_uni_int<std::ranlux24_base, 1ull << 41>);
35+
36+
BENCHMARK_MAIN();

0 commit comments

Comments
 (0)