Skip to content

Commit b00a236

Browse files
committed
[libc++] Make benchmarks forward-compatible with the test suite
This patch fixes a few warnings and errors when running the benchmarks as part of the test suite. It also adds most of the necessary Lit annotations to make it pass on various configurations.
1 parent 1f9953c commit b00a236

File tree

68 files changed

+176
-30
lines changed

Some content is hidden

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

68 files changed

+176
-30
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/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/lower_bound.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 <numeric>
1113
#include <random>

libcxx/test/benchmarks/algorithms/make_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/make_heap_then_sort_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/min.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 <cassert>
1113

libcxx/test/benchmarks/algorithms/min_max_element.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/minmax.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 <cassert>
1113

libcxx/test/benchmarks/algorithms/mismatch.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 <random>

libcxx/test/benchmarks/algorithms/pop_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/pstl.stable_sort.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 <execution>
1113

libcxx/test/benchmarks/algorithms/push_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_contains.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 <iterator>

libcxx/test/benchmarks/algorithms/ranges_ends_with.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 <iterator>

libcxx/test/benchmarks/algorithms/ranges_make_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_make_heap_then_sort_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_pop_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_push_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_sort.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_sort_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/ranges_stable_sort.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/set_intersection.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 <cstdlib>
1113
#include <iterator>

libcxx/test/benchmarks/algorithms/sort.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/sort_heap.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

1113
#include "common.h"

libcxx/test/benchmarks/algorithms/stable_sort.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

1113
#include "common.h"

libcxx/test/benchmarks/allocation.bench.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9+
// REQUIRES: -fsized-deallocation
10+
// ADDITIONAL_COMPILE_FLAGS: -fsized-deallocation
11+
912
#include "benchmark/benchmark.h"
1013

1114
#include <cassert>
15+
#include <cstdlib>
1216
#include <new>
1317
#include <vector>
1418

19+
#include "test_macros.h"
20+
1521
struct PointerList {
1622
PointerList* Next = nullptr;
1723
};
@@ -26,6 +32,7 @@ struct NewWrapper {
2632
__attribute__((always_inline)) static void Deallocate(void* P, size_t) { ::operator delete(P); }
2733
};
2834

35+
#ifdef TEST_COMPILER_CLANG
2936
struct BuiltinNewWrapper {
3037
__attribute__((always_inline)) static void* Allocate(size_t N) { return __builtin_operator_new(N); }
3138
__attribute__((always_inline)) static void Deallocate(void* P, size_t) { __builtin_operator_delete(P); }
@@ -35,6 +42,7 @@ struct BuiltinSizedNewWrapper {
3542
__attribute__((always_inline)) static void* Allocate(size_t N) { return __builtin_operator_new(N); }
3643
__attribute__((always_inline)) static void Deallocate(void* P, size_t N) { __builtin_operator_delete(P, N); }
3744
};
45+
#endif
3846

3947
template <class AllocWrapper>
4048
static void BM_AllocateAndDeallocate(benchmark::State& st) {
@@ -93,11 +101,12 @@ static int RegisterAllocBenchmarks() {
93101
} TestCases[] = {
94102
{"BM_Malloc", &BM_AllocateAndDeallocate<MallocWrapper>},
95103
{"BM_New", &BM_AllocateAndDeallocate<NewWrapper>},
104+
#ifdef TEST_COMPILER_CLANG
96105
{"BM_BuiltinNewDelete", BM_AllocateAndDeallocate<BuiltinNewWrapper>},
97106
{"BM_BuiltinSizedNewDelete", BM_AllocateAndDeallocate<BuiltinSizedNewWrapper>},
98107
{"BM_BuiltinNewAllocateOnly", BM_AllocateOnly<BuiltinSizedNewWrapper>},
99108
{"BM_BuiltinNewSizedDeallocateOnly", BM_DeallocateOnly<BuiltinSizedNewWrapper>},
100-
109+
#endif
101110
};
102111
for (auto TC : TestCases) {
103112
benchmark::RegisterBenchmark(TC.name, TC.func)->Range(16, 4096 * 2);

libcxx/test/benchmarks/atomic_wait.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 <atomic>
1012
#include <numeric>
1113
#include <thread>

libcxx/test/benchmarks/atomic_wait_vs_mutex_lock.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
// To run this test, build libcxx and cxx-benchmarks targets
1012
// cd third-party/benchmark/tools
1113
// ./compare.py filters ../../../build/libcxx/benchmarks/atomic_wait_vs_mutex_lock.libcxx.out BM_atomic_wait BM_mutex

0 commit comments

Comments
 (0)