Skip to content

Commit 763b516

Browse files
committed
Remove redundant benchmark for search_n
1 parent fb8082a commit 763b516

File tree

1 file changed

+1
-53
lines changed

1 file changed

+1
-53
lines changed

libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ int main(int argc, char** argv) {
3838
});
3939
};
4040

41-
// Benchmark {std,ranges}::search_n where the needle is never found
41+
// Benchmark {std,ranges}::search_n where the needle is never found (worst case).
4242
{
4343
auto bm = []<class Container>(std::string name, auto search_n) {
4444
benchmark::RegisterBenchmark(
@@ -81,58 +81,6 @@ int main(int argc, char** argv) {
8181
bm.operator()<std::list<int>>("rng::search_n(list<int>, pred) (no match)", ranges_search_n_pred);
8282
}
8383

84-
// Benchmark {std,ranges}::search_n where we intersperse "near matches" inside the haystack
85-
{
86-
auto bm = []<class Container>(std::string name, auto search_n) {
87-
benchmark::RegisterBenchmark(
88-
name,
89-
[search_n](auto& st) {
90-
std::size_t const size = st.range(0);
91-
using ValueType = typename Container::value_type;
92-
ValueType x = Generate<ValueType>::random();
93-
ValueType y = random_different_from({x});
94-
Container haystack(size, x);
95-
std::size_t n = size / 10; // needle size is 10% of the haystack
96-
assert(n > 0);
97-
98-
// intersperse near-matches inside the haystack
99-
{
100-
auto first = haystack.begin();
101-
for (int i = 0; i != 10; ++i) {
102-
first = std::fill_n(first, n - 1, y);
103-
++first; // this causes the subsequence not to match because it has length n-1
104-
}
105-
}
106-
107-
for ([[maybe_unused]] auto _ : st) {
108-
benchmark::DoNotOptimize(haystack);
109-
benchmark::DoNotOptimize(n);
110-
benchmark::DoNotOptimize(y);
111-
auto result = search_n(haystack.begin(), haystack.end(), n, y);
112-
benchmark::DoNotOptimize(result);
113-
}
114-
})
115-
->Arg(1000) // non power-of-two
116-
->Arg(1024)
117-
->Arg(8192);
118-
};
119-
// {std,ranges}::search_n
120-
bm.operator()<std::vector<int>>("std::search_n(vector<int>) (near matches)", std_search_n);
121-
bm.operator()<std::deque<int>>("std::search_n(deque<int>) (near matches)", std_search_n);
122-
bm.operator()<std::list<int>>("std::search_n(list<int>) (near matches)", std_search_n);
123-
bm.operator()<std::vector<int>>("rng::search_n(vector<int>) (near matches)", std::ranges::search_n);
124-
bm.operator()<std::deque<int>>("rng::search_n(deque<int>) (near matches)", std::ranges::search_n);
125-
bm.operator()<std::list<int>>("rng::search_n(list<int>) (near matches)", std::ranges::search_n);
126-
127-
// {std,ranges}::search_n(pred)
128-
bm.operator()<std::vector<int>>("std::search_n(vector<int>, pred) (near matches)", std_search_n_pred);
129-
bm.operator()<std::deque<int>>("std::search_n(deque<int>, pred) (near matches)", std_search_n_pred);
130-
bm.operator()<std::list<int>>("std::search_n(list<int>, pred) (near matches)", std_search_n_pred);
131-
bm.operator()<std::vector<int>>("rng::search_n(vector<int>, pred) (near matches)", ranges_search_n_pred);
132-
bm.operator()<std::deque<int>>("rng::search_n(deque<int>, pred) (near matches)", ranges_search_n_pred);
133-
bm.operator()<std::list<int>>("rng::search_n(list<int>, pred) (near matches)", ranges_search_n_pred);
134-
}
135-
13684
benchmark::Initialize(&argc, argv);
13785
benchmark::RunSpecifiedBenchmarks();
13886
benchmark::Shutdown();

0 commit comments

Comments
 (0)