File tree Expand file tree Collapse file tree 2 files changed +687
-0
lines changed
std/numerics/rand/rand.dist/rand.dist.uni/rand.dist.uni.int Expand file tree Collapse file tree 2 files changed +687
-0
lines changed Original file line number Diff line number Diff line change 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 ();
You can’t perform that action at this time.
0 commit comments