Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / benchmarks / algorithms / min.bench.cpp
blob1e1dd4e71c2ef120801ada05793d879a86b72d08
1 #include <algorithm>
2 #include <cassert>
4 #include <benchmark/benchmark.h>
6 void run_sizes(auto benchmark) {
7 benchmark->Arg(1)
8 ->Arg(2)
9 ->Arg(3)
10 ->Arg(4)
11 ->Arg(5)
12 ->Arg(6)
13 ->Arg(7)
14 ->Arg(8)
15 ->Arg(9)
16 ->Arg(10)
17 ->Arg(11)
18 ->Arg(12)
19 ->Arg(13)
20 ->Arg(14)
21 ->Arg(15)
22 ->Arg(16)
23 ->Arg(17)
24 ->Arg(18)
25 ->Arg(19)
26 ->Arg(20)
27 ->Arg(21)
28 ->Arg(22)
29 ->Arg(23)
30 ->Arg(24)
31 ->Arg(25)
32 ->Arg(26)
33 ->Arg(27)
34 ->Arg(28)
35 ->Arg(29)
36 ->Arg(30)
37 ->Arg(31)
38 ->Arg(32)
39 ->Arg(64)
40 ->Arg(512)
41 ->Arg(1024)
42 ->Arg(4000)
43 ->Arg(4096)
44 ->Arg(5500)
45 ->Arg(64000)
46 ->Arg(65536)
47 ->Arg(70000);
50 template <class T>
51 static void BM_std_min(benchmark::State& state) {
52 std::vector<T> vec(state.range(), 3);
54 for (auto _ : state) {
55 benchmark::DoNotOptimize(vec);
56 benchmark::DoNotOptimize(std::ranges::min(vec));
59 BENCHMARK(BM_std_min<char>)->Apply(run_sizes);
60 BENCHMARK(BM_std_min<short>)->Apply(run_sizes);
61 BENCHMARK(BM_std_min<int>)->Apply(run_sizes);
62 BENCHMARK(BM_std_min<long long>)->Apply(run_sizes);
63 BENCHMARK(BM_std_min<__int128>)->Apply(run_sizes);
64 BENCHMARK(BM_std_min<unsigned char>)->Apply(run_sizes);
65 BENCHMARK(BM_std_min<unsigned short>)->Apply(run_sizes);
66 BENCHMARK(BM_std_min<unsigned int>)->Apply(run_sizes);
67 BENCHMARK(BM_std_min<unsigned long long>)->Apply(run_sizes);
68 BENCHMARK(BM_std_min<unsigned __int128>)->Apply(run_sizes);
70 BENCHMARK_MAIN();