Skip to content

Commit b2d2494

Browse files
authored
[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.
1 parent 6070aeb commit b2d2494

File tree

73 files changed

+240
-161
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+240
-161
lines changed

libcxx/test/benchmarks/CartesianBenchmarks.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ constexpr auto makeEnumValueTuple(std::index_sequence<Idxs...>) {
2727
}
2828

2929
template <class B>
30-
static auto skip(const B& Bench, int) -> decltype(Bench.skip()) {
30+
auto skip(const B& Bench, int) -> decltype(Bench.skip()) {
3131
return Bench.skip();
3232
}
3333
template <class B>
34-
static auto skip(const B& Bench, char) {
34+
auto skip(const B&, char) {
3535
return false;
3636
}
3737

@@ -51,7 +51,7 @@ void makeBenchmarkFromValues(const std::vector<std::tuple<Args...> >& A) {
5151
}
5252

5353
template <template <class...> class B, class Args, class... U>
54-
void makeBenchmarkImpl(const Args& A, std::tuple<U...> t) {
54+
void makeBenchmarkImpl(const Args& A, std::tuple<U...>) {
5555
makeBenchmarkFromValues<B<U...> >(A);
5656
}
5757

libcxx/test/benchmarks/ContainerBenchmarks.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void BM_EmplaceDuplicate(benchmark::State& st, Container c, GenInputs gen) {
150150
}
151151

152152
template <class Container, class GenInputs>
153-
static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
153+
void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
154154
auto in = gen(st.range(0));
155155
c.insert(in.begin(), in.end());
156156
benchmark::DoNotOptimize(&(*c.begin()));
@@ -164,7 +164,7 @@ static void BM_Find(benchmark::State& st, Container c, GenInputs gen) {
164164
}
165165

166166
template <class Container, class GenInputs>
167-
static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
167+
void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
168168
c.rehash(8);
169169
auto in = gen(st.range(0));
170170
c.insert(in.begin(), in.end());
@@ -179,7 +179,7 @@ static void BM_FindRehash(benchmark::State& st, Container c, GenInputs gen) {
179179
}
180180

181181
template <class Container, class GenInputs>
182-
static void BM_Rehash(benchmark::State& st, Container c, GenInputs gen) {
182+
void BM_Rehash(benchmark::State& st, Container c, GenInputs gen) {
183183
auto in = gen(st.range(0));
184184
c.max_load_factor(3.0);
185185
c.insert(in.begin(), in.end());
@@ -193,7 +193,7 @@ static void BM_Rehash(benchmark::State& st, Container c, GenInputs gen) {
193193
}
194194

195195
template <class Container, class GenInputs>
196-
static void BM_Compare_same_container(benchmark::State& st, Container, GenInputs gen) {
196+
void BM_Compare_same_container(benchmark::State& st, Container, GenInputs gen) {
197197
auto in = gen(st.range(0));
198198
Container c1(in.begin(), in.end());
199199
Container c2 = c1;
@@ -208,7 +208,7 @@ static void BM_Compare_same_container(benchmark::State& st, Container, GenInputs
208208
}
209209

210210
template <class Container, class GenInputs>
211-
static void BM_Compare_different_containers(benchmark::State& st, Container, GenInputs gen) {
211+
void BM_Compare_different_containers(benchmark::State& st, Container, GenInputs gen) {
212212
auto in1 = gen(st.range(0));
213213
auto in2 = gen(st.range(0));
214214
Container c1(in1.begin(), in1.end());

libcxx/test/benchmarks/VariantBenchmarks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ static auto genVariants(std::index_sequence<Is...>) {
3535

3636
std::array<V, N> result = {};
3737
for (auto& v : result) {
38-
v = fs[getRandomInteger(0ul, sizeof...(Is) - 1)]();
38+
v = fs[getRandomInteger(std::size_t(0), sizeof...(Is) - 1)]();
3939
}
4040

4141
return result;

libcxx/test/benchmarks/algorithms.partition_point.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14
10+
911
#include <algorithm>
1012
#include <array>
1113
#include <cassert>

libcxx/test/benchmarks/algorithms/count.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
911
#include <algorithm>
1012
#include <benchmark/benchmark.h>
1113
#include <cstring>

libcxx/test/benchmarks/algorithms/equal.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
911
#include <algorithm>
1012
#include <benchmark/benchmark.h>
1113
#include <vector>

libcxx/test/benchmarks/algorithms/fill.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10+
911
#include <algorithm>
1012
#include <benchmark/benchmark.h>
1113
#include <vector>

libcxx/test/benchmarks/algorithms/find.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
911
#include <algorithm>
1012
#include <benchmark/benchmark.h>
1113
#include <cstring>

libcxx/test/benchmarks/algorithms/for_each.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14
10+
911
#include <algorithm>
1012
#include <benchmark/benchmark.h>
1113
#include <deque>

libcxx/test/benchmarks/algorithms/lexicographical_compare.bench.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// UNSUPPORTED: c++03, c++11, c++14, c++17
10+
911
#include <algorithm>
1012
#include <benchmark/benchmark.h>
1113
#include <vector>

0 commit comments

Comments
 (0)