Skip to content

Commit fb8082a

Browse files
committed
Remove unnecessary benchmark for std::count
1 parent d2907d3 commit fb8082a

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

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

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -80,53 +80,6 @@ int main(int argc, char** argv) {
8080
bm.operator()<std::list<int>>("rng::count_if(list<int>) (every other)", ranges_count_if);
8181
}
8282

83-
// Benchmark {std,ranges}::{count,count_if} on a sequence where only a few elements are counted.
84-
// In theory, we could blaze through contiguous sequences where there are no elements to count.
85-
{
86-
auto bm = []<class Container>(std::string name, auto count) {
87-
benchmark::RegisterBenchmark(
88-
name,
89-
[count](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 c;
95-
for (std::size_t i = 0; i != size; ++i) {
96-
c.push_back(i % (size / 5) == 0 ? x : y); // intersperse 5 elements to count at regular intervals
97-
}
98-
99-
for ([[maybe_unused]] auto _ : st) {
100-
benchmark::DoNotOptimize(c);
101-
benchmark::DoNotOptimize(x);
102-
auto result = count(c.begin(), c.end(), x);
103-
benchmark::DoNotOptimize(result);
104-
}
105-
})
106-
->Arg(8)
107-
->Arg(50) // non power-of-two
108-
->Arg(1024)
109-
->Arg(8192)
110-
->Arg(1 << 20);
111-
};
112-
113-
// count
114-
bm.operator()<std::vector<int>>("std::count(vector<int>) (sparse)", std_count);
115-
bm.operator()<std::deque<int>>("std::count(deque<int>) (sparse)", std_count);
116-
bm.operator()<std::list<int>>("std::count(list<int>) (sparse)", std_count);
117-
bm.operator()<std::vector<int>>("rng::count(vector<int>) (sparse)", ranges_count);
118-
bm.operator()<std::deque<int>>("rng::count(deque<int>) (sparse)", ranges_count);
119-
bm.operator()<std::list<int>>("rng::count(list<int>) (sparse)", ranges_count);
120-
121-
// count_if
122-
bm.operator()<std::vector<int>>("std::count_if(vector<int>) (sparse)", std_count_if);
123-
bm.operator()<std::deque<int>>("std::count_if(deque<int>) (sparse)", std_count_if);
124-
bm.operator()<std::list<int>>("std::count_if(list<int>) (sparse)", std_count_if);
125-
bm.operator()<std::vector<int>>("rng::count_if(vector<int>) (sparse)", ranges_count_if);
126-
bm.operator()<std::deque<int>>("rng::count_if(deque<int>) (sparse)", ranges_count_if);
127-
bm.operator()<std::list<int>>("rng::count_if(list<int>) (sparse)", ranges_count_if);
128-
}
129-
13083
// Benchmark {std,ranges}::count(vector<bool>)
13184
{
13285
auto bm = [](std::string name, auto count) {

0 commit comments

Comments
 (0)