From b2d2494731976ab7aa9702f3134472db694b9332 Mon Sep 17 00:00:00 2001 From: Louis Dionne Date: Tue, 5 Nov 2024 09:08:00 -0500 Subject: [PATCH] [libc++] Make benchmarks forward-compatible with the test suite (#114502) This patch fixes warnings and errors that come up when running the benchmarks as part of the test suite. It also adds the necessary Lit annotations to make it pass in various configurations and increases the portability of the benchmarks. --- libcxx/test/benchmarks/CartesianBenchmarks.h | 6 +- libcxx/test/benchmarks/ContainerBenchmarks.h | 10 +- libcxx/test/benchmarks/VariantBenchmarks.h | 2 +- .../algorithms.partition_point.bench.cpp | 2 + .../benchmarks/algorithms/count.bench.cpp | 2 + .../benchmarks/algorithms/equal.bench.cpp | 2 + .../test/benchmarks/algorithms/fill.bench.cpp | 2 + .../test/benchmarks/algorithms/find.bench.cpp | 2 + .../benchmarks/algorithms/for_each.bench.cpp | 2 + .../lexicographical_compare.bench.cpp | 2 + .../algorithms/lower_bound.bench.cpp | 2 + .../benchmarks/algorithms/make_heap.bench.cpp | 2 + .../make_heap_then_sort_heap.bench.cpp | 2 + .../test/benchmarks/algorithms/min.bench.cpp | 5 + .../algorithms/min_max_element.bench.cpp | 2 + .../benchmarks/algorithms/minmax.bench.cpp | 2 + .../benchmarks/algorithms/mismatch.bench.cpp | 2 + .../benchmarks/algorithms/pop_heap.bench.cpp | 2 + .../algorithms/pstl.stable_sort.bench.cpp | 3 + .../benchmarks/algorithms/push_heap.bench.cpp | 2 + .../algorithms/ranges_contains.bench.cpp | 2 + .../algorithms/ranges_ends_with.bench.cpp | 2 + .../algorithms/ranges_make_heap.bench.cpp | 2 + .../ranges_make_heap_then_sort_heap.bench.cpp | 2 + .../algorithms/ranges_pop_heap.bench.cpp | 2 + .../algorithms/ranges_push_heap.bench.cpp | 2 + .../algorithms/ranges_sort.bench.cpp | 2 + .../algorithms/ranges_sort_heap.bench.cpp | 2 + .../algorithms/ranges_stable_sort.bench.cpp | 2 + .../algorithms/set_intersection.bench.cpp | 2 + .../test/benchmarks/algorithms/sort.bench.cpp | 2 + .../benchmarks/algorithms/sort_heap.bench.cpp | 2 + .../algorithms/stable_sort.bench.cpp | 2 + libcxx/test/benchmarks/allocation.bench.cpp | 11 ++- libcxx/test/benchmarks/atomic_wait.bench.cpp | 3 + .../atomic_wait_vs_mutex_lock.bench.cpp | 3 + libcxx/test/benchmarks/deque.bench.cpp | 2 + .../test/benchmarks/deque_iterator.bench.cpp | 2 + .../test/benchmarks/exception_ptr.bench.cpp | 2 + libcxx/test/benchmarks/filesystem.bench.cpp | 2 + libcxx/test/benchmarks/format.bench.cpp | 5 + .../format/write_double_comparison.bench.cpp | 7 +- .../format/write_int_comparison.bench.cpp | 7 +- .../format/write_string_comparison.bench.cpp | 19 ++-- libcxx/test/benchmarks/format_to.bench.cpp | 5 + libcxx/test/benchmarks/format_to_n.bench.cpp | 5 + .../test/benchmarks/formatted_size.bench.cpp | 5 + .../test/benchmarks/formatter_float.bench.cpp | 10 +- .../test/benchmarks/formatter_int.bench.cpp | 5 + libcxx/test/benchmarks/function.bench.cpp | 6 +- libcxx/test/benchmarks/hash.bench.cpp | 38 -------- libcxx/test/benchmarks/join_view.bench.cpp | 2 + ...exicographical_compare_three_way.bench.cpp | 2 + .../libcxxabi/dynamic_cast.bench.cpp | 2 + .../dynamic_cast_old_stress.bench.cpp | 2 + libcxx/test/benchmarks/map.bench.cpp | 2 + .../benchmarks/monotonic_buffer.bench.cpp | 2 + libcxx/test/benchmarks/numeric/gcd.bench.cpp | 5 +- libcxx/test/benchmarks/ordered_set.bench.cpp | 7 +- libcxx/test/benchmarks/random.bench.cpp | 3 + .../shared_mutex_vs_mutex.bench.cpp | 2 + .../std_format_spec_string_unicode.bench.cpp | 7 +- ...ormat_spec_string_unicode_escape.bench.cpp | 7 +- libcxx/test/benchmarks/stop_token.bench.cpp | 3 + libcxx/test/benchmarks/string.bench.cpp | 28 ++++-- libcxx/test/benchmarks/stringstream.bench.cpp | 2 + libcxx/test/benchmarks/system_error.bench.cpp | 2 + libcxx/test/benchmarks/to_chars.bench.cpp | 2 + .../unordered_set_operations.bench.cpp | 94 +++---------------- .../test/benchmarks/variant_visit_1.bench.cpp | 2 + .../test/benchmarks/variant_visit_2.bench.cpp | 2 + .../test/benchmarks/variant_visit_3.bench.cpp | 2 + .../benchmarks/vector_operations.bench.cpp | 2 + 73 files changed, 240 insertions(+), 161 deletions(-) diff --git a/libcxx/test/benchmarks/CartesianBenchmarks.h b/libcxx/test/benchmarks/CartesianBenchmarks.h index eca4e15cd009bc..c712230843ebf4 100644 --- a/libcxx/test/benchmarks/CartesianBenchmarks.h +++ b/libcxx/test/benchmarks/CartesianBenchmarks.h @@ -27,11 +27,11 @@ constexpr auto makeEnumValueTuple(std::index_sequence) { } template -static auto skip(const B& Bench, int) -> decltype(Bench.skip()) { +auto skip(const B& Bench, int) -> decltype(Bench.skip()) { return Bench.skip(); } template -static auto skip(const B& Bench, char) { +auto skip(const B&, char) { return false; } @@ -51,7 +51,7 @@ void makeBenchmarkFromValues(const std::vector >& A) { } template