diff --git a/benchmarks/cpl/merge_sort/bench.cpp b/benchmarks/cpl/merge_sort/bench.cpp new file mode 100644 index 0000000..376091f --- /dev/null +++ b/benchmarks/cpl/merge_sort/bench.cpp @@ -0,0 +1,40 @@ +// Copyright (c) Brandon Pacewic +// SPDX-License-Identifier: MIT + +#include +#include +#include +#include +#include + +#include "container.h" + +using namespace std; +using namespace cpl; + +template +void bench(benchmark::State& state) { + mt19937 gen(96337); + + const size_t size = static_cast(state.range(0)); + + vector input(size); + + uniform_int_distribution dist(numeric_limits::min(), numeric_limits::max()); + ranges::generate(input, [&] { return dist(gen); }); + + for (auto _ : state) { + benchmark::DoNotOptimize(input); + benchmark::DoNotOptimize(merge_sort(input)); + } +} + +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wignored-attributes" +BENCHMARK(bench)->Range(8, 8 << 10); +BENCHMARK(bench)->Range(8, 8 << 10); +BENCHMARK(bench)->Range(8, 8 << 10); +BENCHMARK(bench)->Range(8, 8 << 10); +#pragma GCC diagnostic pop + +BENCHMARK_MAIN();