Skip to content

Commit 0512a04

Browse files
committed
Use 90% and 10% for symmetry
1 parent c5e9ab3 commit 0512a04

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

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

Lines changed: 10 additions & 10 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}::find_first_of where we have a hit at 25% of the haystack
41+
// Benchmark {std,ranges}::find_first_of where we have a hit at 10% of the haystack
4242
// and at the end of the needle. This measures how quickly we're able to search inside
4343
// the needle.
4444
{
@@ -55,8 +55,8 @@ int main(int argc, char** argv) {
5555
Container needle(size, y);
5656
needle.back() = z; // hit at the very end of the needle
5757

58-
// put the needle at 25% of the haystack
59-
*std::next(haystack.begin(), haystack.size() / 4) = z;
58+
// put the needle at 10% of the haystack
59+
*std::next(haystack.begin(), haystack.size() / 10) = z;
6060

6161
for ([[maybe_unused]] auto _ : st) {
6262
benchmark::DoNotOptimize(haystack);
@@ -71,15 +71,15 @@ int main(int argc, char** argv) {
7171
->Arg(8192);
7272
};
7373
// {std,ranges}::find_first_of(it1, it1, it2, it2)
74-
bm.operator()<std::vector<int>>("std::find_first_of(vector<int>) (25% haystack, late needle)", std_find_first_of);
75-
bm.operator()<std::deque<int>>("std::find_first_of(deque<int>) (25% haystack, late needle)", std_find_first_of);
76-
bm.operator()<std::list<int>>("std::find_first_of(list<int>) (25% haystack, late needle)", std_find_first_of);
74+
bm.operator()<std::vector<int>>("std::find_first_of(vector<int>) (10% haystack, late needle)", std_find_first_of);
75+
bm.operator()<std::deque<int>>("std::find_first_of(deque<int>) (10% haystack, late needle)", std_find_first_of);
76+
bm.operator()<std::list<int>>("std::find_first_of(list<int>) (10% haystack, late needle)", std_find_first_of);
7777
bm.operator()<std::vector<int>>(
78-
"rng::find_first_of(vector<int>) (25% haystack, late needle)", std::ranges::find_first_of);
78+
"rng::find_first_of(vector<int>) (10% haystack, late needle)", std::ranges::find_first_of);
7979
bm.operator()<std::deque<int>>(
80-
"rng::find_first_of(deque<int>) (25% haystack, late needle)", std::ranges::find_first_of);
80+
"rng::find_first_of(deque<int>) (10% haystack, late needle)", std::ranges::find_first_of);
8181
bm.operator()<std::list<int>>(
82-
"rng::find_first_of(list<int>) (25% haystack, late needle)", std::ranges::find_first_of);
82+
"rng::find_first_of(list<int>) (10% haystack, late needle)", std::ranges::find_first_of);
8383

8484
// {std,ranges}::find_first_of(it1, it1, it2, it2, pred)
8585
bm.operator()<std::vector<int>>(
@@ -113,7 +113,7 @@ int main(int argc, char** argv) {
113113
*std::next(needle.begin(), needle.size() / 10) = z; // hit at 10% of the needle
114114

115115
// put the needle at 90% of the haystack
116-
*std::next(haystack.begin(), 9 * (haystack.size() / 10)) = z;
116+
*std::next(haystack.begin(), (9 * haystack.size()) / 10) = z;
117117

118118
for ([[maybe_unused]] auto _ : st) {
119119
benchmark::DoNotOptimize(haystack);

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

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ int main(int argc, char** argv) {
3434
};
3535

3636
// Benchmark ranges::{find_last,find_last_if,find_last_if_not} where the last element
37-
// is found 25% into the sequence
37+
// is found 10% into the sequence
3838
{
3939
auto bm = []<class Container>(std::string name, auto find_last) {
4040
benchmark::RegisterBenchmark(
@@ -46,8 +46,8 @@ int main(int argc, char** argv) {
4646
ValueType y = random_different_from({x});
4747
Container c(size, x);
4848

49-
// put the element we're searching for at 25% of the sequence
50-
*std::next(c.begin(), size / 4) = y;
49+
// put the element we're searching for at 10% of the sequence
50+
*std::next(c.begin(), size / 10) = y;
5151

5252
for ([[maybe_unused]] auto _ : st) {
5353
benchmark::DoNotOptimize(c);
@@ -64,26 +64,26 @@ int main(int argc, char** argv) {
6464
};
6565

6666
// find_last
67-
bm.operator()<std::vector<char>>("rng::find_last(vector<char>) (bail 25%)", std::ranges::find_last);
68-
bm.operator()<std::vector<int>>("rng::find_last(vector<int>) (bail 25%)", std::ranges::find_last);
69-
bm.operator()<std::deque<int>>("rng::find_last(deque<int>) (bail 25%)", std::ranges::find_last);
70-
bm.operator()<std::list<int>>("rng::find_last(list<int>) (bail 25%)", std::ranges::find_last);
71-
bm.operator()<std::forward_list<int>>("rng::find_last(forward_list<int>) (bail 25%)", std::ranges::find_last);
67+
bm.operator()<std::vector<char>>("rng::find_last(vector<char>) (bail 10%)", std::ranges::find_last);
68+
bm.operator()<std::vector<int>>("rng::find_last(vector<int>) (bail 10%)", std::ranges::find_last);
69+
bm.operator()<std::deque<int>>("rng::find_last(deque<int>) (bail 10%)", std::ranges::find_last);
70+
bm.operator()<std::list<int>>("rng::find_last(list<int>) (bail 10%)", std::ranges::find_last);
71+
bm.operator()<std::forward_list<int>>("rng::find_last(forward_list<int>) (bail 10%)", std::ranges::find_last);
7272

7373
// find_last_if
74-
bm.operator()<std::vector<char>>("rng::find_last_if(vector<char>) (bail 25%)", ranges_find_last_if);
75-
bm.operator()<std::vector<int>>("rng::find_last_if(vector<int>) (bail 25%)", ranges_find_last_if);
76-
bm.operator()<std::deque<int>>("rng::find_last_if(deque<int>) (bail 25%)", ranges_find_last_if);
77-
bm.operator()<std::list<int>>("rng::find_last_if(list<int>) (bail 25%)", ranges_find_last_if);
78-
bm.operator()<std::forward_list<int>>("rng::find_last_if(forward_list<int>) (bail 25%)", ranges_find_last_if);
74+
bm.operator()<std::vector<char>>("rng::find_last_if(vector<char>) (bail 10%)", ranges_find_last_if);
75+
bm.operator()<std::vector<int>>("rng::find_last_if(vector<int>) (bail 10%)", ranges_find_last_if);
76+
bm.operator()<std::deque<int>>("rng::find_last_if(deque<int>) (bail 10%)", ranges_find_last_if);
77+
bm.operator()<std::list<int>>("rng::find_last_if(list<int>) (bail 10%)", ranges_find_last_if);
78+
bm.operator()<std::forward_list<int>>("rng::find_last_if(forward_list<int>) (bail 10%)", ranges_find_last_if);
7979

8080
// find_last_if_not
81-
bm.operator()<std::vector<char>>("rng::find_last_if_not(vector<char>) (bail 25%)", ranges_find_last_if_not);
82-
bm.operator()<std::vector<int>>("rng::find_last_if_not(vector<int>) (bail 25%)", ranges_find_last_if_not);
83-
bm.operator()<std::deque<int>>("rng::find_last_if_not(deque<int>) (bail 25%)", ranges_find_last_if_not);
84-
bm.operator()<std::list<int>>("rng::find_last_if_not(list<int>) (bail 25%)", ranges_find_last_if_not);
81+
bm.operator()<std::vector<char>>("rng::find_last_if_not(vector<char>) (bail 10%)", ranges_find_last_if_not);
82+
bm.operator()<std::vector<int>>("rng::find_last_if_not(vector<int>) (bail 10%)", ranges_find_last_if_not);
83+
bm.operator()<std::deque<int>>("rng::find_last_if_not(deque<int>) (bail 10%)", ranges_find_last_if_not);
84+
bm.operator()<std::list<int>>("rng::find_last_if_not(list<int>) (bail 10%)", ranges_find_last_if_not);
8585
bm.operator()<std::forward_list<int>>(
86-
"rng::find_last_if_not(forward_list<int>) (bail 25%)", ranges_find_last_if_not);
86+
"rng::find_last_if_not(forward_list<int>) (bail 10%)", ranges_find_last_if_not);
8787
}
8888

8989
// Benchmark ranges::{find_last,find_last_if,find_last_if_not} where the last element
@@ -100,7 +100,7 @@ int main(int argc, char** argv) {
100100
Container c(size, x);
101101

102102
// put the element we're searching for at 90% of the sequence
103-
*std::next(c.begin(), 9 * (size / 10)) = y;
103+
*std::next(c.begin(), (9 * size) / 10) = y;
104104

105105
for ([[maybe_unused]] auto _ : st) {
106106
benchmark::DoNotOptimize(c);

0 commit comments

Comments
 (0)