File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
benchmarks/cpl/merge_sort Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright (c) Brandon Pacewic
2+ // SPDX-License-Identifier: MIT
3+
4+ #include < algorithm>
5+ #include < benchmark/benchmark.h>
6+ #include < cstdint>
7+ #include < random>
8+ #include < vector>
9+
10+ #include " container.h"
11+
12+ using namespace std ;
13+ using namespace cpl ;
14+
15+ template <class T >
16+ void bench (benchmark::State& state) {
17+ mt19937 gen (96337 );
18+
19+ const size_t size = static_cast <size_t >(state.range (0 ));
20+
21+ vector<T> input (size);
22+
23+ uniform_int_distribution<T> dist (numeric_limits<T>::min (), numeric_limits<T>::max ());
24+ ranges::generate (input, [&] { return dist (gen); });
25+
26+ for (auto _ : state) {
27+ benchmark::DoNotOptimize (input);
28+ benchmark::DoNotOptimize (merge_sort (input));
29+ }
30+ }
31+
32+ #pragma GCC diagnostic push
33+ #pragma GCC diagnostic ignored "-Wignored-attributes"
34+ BENCHMARK (bench<int8_t >)->Range(8 , 8 << 10 );
35+ BENCHMARK (bench<int16_t >)->Range(8 , 8 << 10 );
36+ BENCHMARK (bench<int32_t >)->Range(8 , 8 << 10 );
37+ BENCHMARK (bench<int64_t >)->Range(8 , 8 << 10 );
38+ #pragma GCC diagnostic pop
39+
40+ BENCHMARK_MAIN ();
You can’t perform that action at this time.
0 commit comments