@@ -23,6 +23,20 @@ int main(int argc, char** argv) {
2323 auto std_find_first_of = [](auto first1, auto last1, auto first2, auto last2) {
2424 return std::find_first_of (first1, last1, first2, last2);
2525 };
26+ auto std_find_first_of_pred = [](auto first1, auto last1, auto first2, auto last2) {
27+ return std::find_first_of (first1, last1, first2, last2, [](auto x, auto y) {
28+ benchmark::DoNotOptimize (x);
29+ benchmark::DoNotOptimize (y);
30+ return x == y;
31+ });
32+ };
33+ auto ranges_find_first_of_pred = [](auto first1, auto last1, auto first2, auto last2) {
34+ return std::ranges::find_first_of (first1, last1, first2, last2, [](auto x, auto y) {
35+ benchmark::DoNotOptimize (x);
36+ benchmark::DoNotOptimize (y);
37+ return x == y;
38+ });
39+ };
2640
2741 // Benchmark {std,ranges}::find_first_of where we have a hit at 25% of the haystack
2842 // and at the end of the needle. This measures how quickly we're able to search inside
@@ -55,6 +69,7 @@ int main(int argc, char** argv) {
5569 ->Arg (1024 )
5670 ->Arg (8192 );
5771 };
72+ // {std,ranges}::find_first_of(it1, it1, it2, it2)
5873 bm.operator ()<std::vector<int >>(" std::find_first_of(vector<int>) (25% haystack, late needle)" , std_find_first_of);
5974 bm.operator ()<std::deque<int >>(" std::find_first_of(deque<int>) (25% haystack, late needle)" , std_find_first_of);
6075 bm.operator ()<std::list<int >>(" std::find_first_of(list<int>) (25% haystack, late needle)" , std_find_first_of);
@@ -64,6 +79,19 @@ int main(int argc, char** argv) {
6479 " rng::find_first_of(deque<int>) (25% haystack, late needle)" , std::ranges::find_first_of);
6580 bm.operator ()<std::list<int >>(
6681 " rng::find_first_of(list<int>) (25% haystack, late needle)" , std::ranges::find_first_of);
82+
83+ // {std,ranges}::find_first_of(it1, it1, it2, it2, pred)
84+ bm.operator ()<std::vector<int >>(
85+ " std::find_first_of(vector<int>, pred) (25% haystack, late needle)" , std_find_first_of);
86+ bm.operator ()<std::deque<int >>(
87+ " std::find_first_of(deque<int>, pred) (25% haystack, late needle)" , std_find_first_of);
88+ bm.operator ()<std::list<int >>(" std::find_first_of(list<int>, pred) (25% haystack, late needle)" , std_find_first_of);
89+ bm.operator ()<std::vector<int >>(
90+ " rng::find_first_of(vector<int>, pred) (25% haystack, late needle)" , std::ranges::find_first_of);
91+ bm.operator ()<std::deque<int >>(
92+ " rng::find_first_of(deque<int>, pred) (25% haystack, late needle)" , std::ranges::find_first_of);
93+ bm.operator ()<std::list<int >>(
94+ " rng::find_first_of(list<int>, pred) (25% haystack, late needle)" , std::ranges::find_first_of);
6795 }
6896
6997 // Benchmark {std,ranges}::find_first_of where we have a hit at 90% of the haystack
@@ -97,6 +125,7 @@ int main(int argc, char** argv) {
97125 ->Arg (1024 )
98126 ->Arg (8192 );
99127 };
128+ // {std,ranges}::find_first_of(it1, it1, it2, it2)
100129 bm.operator ()<std::vector<int >>(" std::find_first_of(vector<int>) (90% haystack, early needle)" , std_find_first_of);
101130 bm.operator ()<std::deque<int >>(" std::find_first_of(deque<int>) (90% haystack, early needle)" , std_find_first_of);
102131 bm.operator ()<std::list<int >>(" std::find_first_of(list<int>) (90% haystack, early needle)" , std_find_first_of);
@@ -106,6 +135,20 @@ int main(int argc, char** argv) {
106135 " rng::find_first_of(deque<int>) (90% haystack, early needle)" , std::ranges::find_first_of);
107136 bm.operator ()<std::list<int >>(
108137 " rng::find_first_of(list<int>) (90% haystack, early needle)" , std::ranges::find_first_of);
138+
139+ // {std,ranges}::find_first_of(it1, it1, it2, it2, pred)
140+ bm.operator ()<std::vector<int >>(
141+ " std::find_first_of(vector<int>, pred) (90% haystack, early needle)" , std_find_first_of_pred);
142+ bm.operator ()<std::deque<int >>(
143+ " std::find_first_of(deque<int>, pred) (90% haystack, early needle)" , std_find_first_of_pred);
144+ bm.operator ()<std::list<int >>(
145+ " std::find_first_of(list<int>, pred) (90% haystack, early needle)" , std_find_first_of_pred);
146+ bm.operator ()<std::vector<int >>(
147+ " rng::find_first_of(vector<int>, pred) (90% haystack, early needle)" , ranges_find_first_of_pred);
148+ bm.operator ()<std::deque<int >>(
149+ " rng::find_first_of(deque<int>, pred) (90% haystack, early needle)" , ranges_find_first_of_pred);
150+ bm.operator ()<std::list<int >>(
151+ " rng::find_first_of(list<int>, pred) (90% haystack, early needle)" , ranges_find_first_of_pred);
109152 }
110153
111154 benchmark::Initialize (&argc, argv);
0 commit comments