File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
libcxx/test/benchmarks/numeric Expand file tree Collapse file tree 1 file changed +37
-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 < 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 ();
You can’t perform that action at this time.
0 commit comments