From baedc8e618d32188df17ebabe4a058d7f2493a0c Mon Sep 17 00:00:00 2001 From: Vaibhav Pathak Date: Thu, 25 Jul 2024 23:43:53 +0530 Subject: [PATCH] [libc++] Fix formatting and move min_element.bench.cpp --- .../algorithms/min_element.bench.cpp | 80 +++++++++++++++++++ libcxx/benchmarks/min_element.bench.cpp | 48 ----------- 2 files changed, 80 insertions(+), 48 deletions(-) create mode 100644 libcxx/benchmarks/algorithms/min_element.bench.cpp delete mode 100644 libcxx/benchmarks/min_element.bench.cpp diff --git a/libcxx/benchmarks/algorithms/min_element.bench.cpp b/libcxx/benchmarks/algorithms/min_element.bench.cpp new file mode 100644 index 00000000000000..7edb8ddbb15f29 --- /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 ed769aeeea7d27..00000000000000 --- 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();