diff --git a/libcxx/benchmarks/algorithms/min_element.bench.cpp b/libcxx/benchmarks/algorithms/min_element.bench.cpp new file mode 100644 index 000000000000000..7edb8ddbb15f29b --- /dev/null +++ b/libcxx/benchmarks/algorithms/min_element.bench.cpp @@ -0,0 +1,80 @@ +#include +#include +#include + +#include +#include + +template +static void BM_stdmin_element_decreasing(benchmark::State& state) { + std::vector v(state.range(0)); + T start = std::numeric_limits::max(); + T end = std::numeric_limits::min(); + + for (size_t i = 0; i < v.size(); i++) + v[i] = ((start != end) ? start-- : end); + + for (auto _ : state) { + benchmark::DoNotOptimize(v); + benchmark::DoNotOptimize(std::min_element(v.begin(), v.end())); + } +} + +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); +BENCHMARK(BM_stdmin_element_decreasing) + ->DenseRange(1, 8) + ->Range(32, 128) + ->Range(256, 4096) + ->DenseRange(5000, 10000, 1000) + ->Range(1 << 14, 1 << 16) + ->Arg(70000); + +BENCHMARK_MAIN(); diff --git a/libcxx/benchmarks/min_element.bench.cpp b/libcxx/benchmarks/min_element.bench.cpp deleted file mode 100644 index ed769aeeea7d27a..000000000000000 --- a/libcxx/benchmarks/min_element.bench.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include -#include -#include - -#include -#include - -template -static void BM_stdmin_element_decreasing(benchmark::State &state){ - std::vector v(state.range(0)); - T start = std::numeric_limits::max(); - T end = std::numeric_limits::min(); - - for(size_t i = 0; i < v.size(); i++) - v[i] = ((start != end) ? start-- : end); - - for(auto _ : state){ - benchmark::DoNotOptimize(v); - benchmark::DoNotOptimize(std::min_element(v.begin(), v.end())); - } -} - -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); -BENCHMARK(BM_stdmin_element_decreasing) - ->DenseRange(1, 8)->Range(32, 128)->Range(256, 4096)->DenseRange(5000, 10000, 1000) - ->Range(1<<14, 1<<16)->Arg(70000); - -BENCHMARK_MAIN();