[libcxx-commits] [libcxx] [libc++] Remove benchmark::DoNotOptimize from custom predicates in benchmarks (PR #208412)
Nikolas Klauser via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 9 03:15:46 PDT 2026
https://github.com/philnik777 created https://github.com/llvm/llvm-project/pull/208412
The point of the custom predicates is to defeat any detection of special predicates. There isn't much point in adding `benchmark::DoNotOptimize` on top of that. It can actually hurt, since it may hide performance changes due to how much/which information we provide to the compiler.
>From 2668f12f8b28cc0faf5dbe5e8b35dcbeeab3e332 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser <nikolasklauser at berlin.de>
Date: Thu, 9 Jul 2026 12:13:18 +0200
Subject: [PATCH] [libc++] Remove benchmark::DoNotOptimize from custom
predicates in benchmarks
---
.../benchmarks/algorithms/modifying/remove.bench.cpp | 5 +----
.../algorithms/modifying/replace.bench.cpp | 5 +----
.../algorithms/modifying/transform.binary.bench.cpp | 6 +-----
.../algorithms/modifying/transform.unary.bench.cpp | 5 +----
.../benchmarks/algorithms/modifying/unique.bench.cpp | 6 +-----
.../algorithms/modifying/unique_copy.bench.cpp | 6 +-----
.../algorithms/nonmodifying/adjacent_find.bench.cpp | 6 +-----
.../nonmodifying/any_all_none_of.bench.cpp | 5 +----
.../algorithms/nonmodifying/count.bench.cpp | 5 +----
.../algorithms/nonmodifying/ends_with.bench.cpp | 6 +-----
.../algorithms/nonmodifying/equal.bench.cpp | 12 ++----------
.../algorithms/nonmodifying/find_end.bench.cpp | 6 +-----
.../algorithms/nonmodifying/find_first_of.bench.cpp | 6 +-----
.../algorithms/nonmodifying/find_last.bench.cpp | 10 ++--------
.../algorithms/nonmodifying/fold.bench.cpp | 6 +-----
.../algorithms/nonmodifying/is_permutation.bench.cpp | 12 ++----------
.../algorithms/nonmodifying/mismatch.bench.cpp | 12 ++----------
.../algorithms/nonmodifying/search.bench.cpp | 6 +-----
.../algorithms/nonmodifying/search_n.bench.cpp | 6 +-----
.../algorithms/nonmodifying/starts_with.bench.cpp | 6 +-----
.../algorithms/sorting/is_sorted.bench.cpp | 6 +-----
.../algorithms/sorting/is_sorted_until.bench.cpp | 6 +-----
22 files changed, 26 insertions(+), 123 deletions(-)
diff --git a/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
index cf5346113264e..e125b73d8cd61 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/remove.bench.cpp
@@ -22,10 +22,7 @@
int main(int argc, char** argv) {
auto std_remove = [](auto first, auto last, auto const& value) { return std::remove(first, last, value); };
auto std_remove_if = [](auto first, auto last, auto const& value) {
- return std::remove_if(first, last, [&](auto element) {
- benchmark::DoNotOptimize(element);
- return element == value;
- });
+ return std::remove_if(first, last, [&](auto element) { return element == value; });
};
// Benchmark {std,ranges}::{remove,remove_if} on a sequence of the form xxxxxxxxxxyyyyyyyyyy
diff --git a/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
index be55d4d6cdc60..287bc40089e35 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/replace.bench.cpp
@@ -22,10 +22,7 @@
int main(int argc, char** argv) {
auto std_replace = [](auto first, auto last, auto old, auto new_) { return std::replace(first, last, old, new_); };
auto std_replace_if = [](auto first, auto last, auto old, auto new_) {
- auto pred = [&](auto element) {
- benchmark::DoNotOptimize(element);
- return element == old;
- };
+ auto pred = [&](auto element) { return element == old; };
return std::replace_if(first, last, pred, new_);
};
diff --git a/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
index 8da1048b58f53..09118cd3bcdf3 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/transform.binary.bench.cpp
@@ -38,11 +38,7 @@ int main(int argc, char** argv) {
std::vector<ValueType> out(size);
- auto f = [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x + y;
- };
+ auto f = [](auto x, auto y) { return x + y; };
for ([[maybe_unused]] auto _ : st) {
benchmark::DoNotOptimize(c1);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
index c640064d4a138..44c7a47db3965 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/transform.unary.bench.cpp
@@ -35,10 +35,7 @@ int main(int argc, char** argv) {
std::vector<ValueType> out(size);
- auto f = [](auto element) {
- benchmark::DoNotOptimize(element);
- return element;
- };
+ auto f = [](auto element) { return element; };
for ([[maybe_unused]] auto _ : st) {
benchmark::DoNotOptimize(c);
diff --git a/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
index 05e1681c9840a..5529afc9d5b97 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/unique.bench.cpp
@@ -22,11 +22,7 @@
int main(int argc, char** argv) {
auto std_unique = [](auto first, auto last) { return std::unique(first, last); };
auto std_unique_pred = [](auto first, auto last) {
- return std::unique(first, last, [](auto a, auto b) {
- benchmark::DoNotOptimize(a);
- benchmark::DoNotOptimize(b);
- return a == b;
- });
+ return std::unique(first, last, [](auto a, auto b) { return a == b; });
};
// Create a sequence of the form xxxxxxxxxxyyyyyyyyyy and unique the
diff --git a/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp b/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
index 75b7ccfa7921a..baca916a51aa0 100644
--- a/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/modifying/unique_copy.bench.cpp
@@ -22,11 +22,7 @@
int main(int argc, char** argv) {
auto std_unique_copy = [](auto first, auto last, auto out) { return std::unique_copy(first, last, out); };
auto std_unique_copy_pred = [](auto first, auto last, auto out) {
- return std::unique_copy(first, last, out, [](auto a, auto b) {
- benchmark::DoNotOptimize(a);
- benchmark::DoNotOptimize(b);
- return a == b;
- });
+ return std::unique_copy(first, last, out, [](auto a, auto b) { return a == b; });
};
// Create a sequence of the form xxxxxxxxxxyyyyyyyyyy and unique the
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
index b9d7fc2e6c530..e67b5cd31a1a6 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/adjacent_find.bench.cpp
@@ -21,11 +21,7 @@
int main(int argc, char** argv) {
auto std_adjacent_find = [](auto first, auto last) { return std::adjacent_find(first, last); };
auto std_adjacent_find_pred = [](auto first, auto last) {
- return std::adjacent_find(first, last, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::adjacent_find(first, last, [](auto x, auto y) { return x == y; });
};
// Benchmark {std,ranges}::adjacent_find on a sequence of the form xyxyxyxyxyxyxyxyxyxy,
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
index 946adfa545836..cf2eb996ddffc 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/any_all_none_of.bench.cpp
@@ -45,10 +45,7 @@ int main(int argc, char** argv) {
for ([[maybe_unused]] auto _ : st) {
benchmark::DoNotOptimize(c);
- auto result = any_of(c.begin(), c.end(), [&](auto element) {
- benchmark::DoNotOptimize(element);
- return element == y;
- });
+ auto result = any_of(c.begin(), c.end(), [&](auto element) { return element == y; });
benchmark::DoNotOptimize(result);
}
})
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
index 0ab5b2493ce75..edffcbb58780c 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/count.bench.cpp
@@ -21,10 +21,7 @@
int main(int argc, char** argv) {
auto std_count = [](auto first, auto last, auto const& value) { return std::count(first, last, value); };
auto std_count_if = [](auto first, auto last, auto const& value) {
- return std::count_if(first, last, [&](auto element) {
- benchmark::DoNotOptimize(element);
- return element == value;
- });
+ return std::count_if(first, last, [&](auto element) { return element == value; });
};
// Benchmark {std,ranges}::{count,count_if} on a sequence where every other element is counted.
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
index 0c01833453156..f2b51a73f428e 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/ends_with.bench.cpp
@@ -22,11 +22,7 @@
int main(int argc, char** argv) {
auto ranges_ends_with_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::ranges::ends_with(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::ranges::ends_with(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
// Benchmark ranges::ends_with where we find the mismatching element at the very end.
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
index 51f819013fed0..4ee194b431bac 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/equal.bench.cpp
@@ -24,18 +24,10 @@ int main(int argc, char** argv) {
return std::equal(first1, last1, first2, last2);
};
auto std_equal_3leg_pred = [](auto first1, auto last1, auto first2, auto) {
- return std::equal(first1, last1, first2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::equal(first1, last1, first2, [](auto x, auto y) { return x == y; });
};
auto std_equal_4leg_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::equal(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::equal(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
// Benchmark {std,ranges}::equal where we determine inequality at the very end (worst case).
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
index 1d5f7d8409719..86cba1be38cc0 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find_end.bench.cpp
@@ -25,11 +25,7 @@ int main(int argc, char** argv) {
return std::find_end(first1, last1, first2, last2);
};
auto std_find_end_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::find_end(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::find_end(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
auto register_benchmarks = [&](auto bm, std::string comment) {
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
index 68c475cb69ffe..3c00db8dafbd8 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find_first_of.bench.cpp
@@ -24,11 +24,7 @@ int main(int argc, char** argv) {
return std::find_first_of(first1, last1, first2, last2);
};
auto std_find_first_of_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::find_first_of(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::find_first_of(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
// Benchmark {std,ranges}::find_first_of where we never find a match in the needle, and the needle is small.
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
index 17074250c6c72..763a8596103c8 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/find_last.bench.cpp
@@ -21,16 +21,10 @@
int main(int argc, char** argv) {
auto ranges_find_last_if = [](auto first, auto last, auto const& value) {
- return std::ranges::find_last_if(first, last, [&](auto element) {
- benchmark::DoNotOptimize(element);
- return element == value;
- });
+ return std::ranges::find_last_if(first, last, [&](auto element) { return element == value; });
};
auto ranges_find_last_if_not = [](auto first, auto last, auto const& value) {
- return std::ranges::find_last_if_not(first, last, [&](auto element) {
- benchmark::DoNotOptimize(element);
- return element != value;
- });
+ return std::ranges::find_last_if_not(first, last, [&](auto element) { return element != value; });
};
// Benchmark ranges::{find_last,find_last_if,find_last_if_not} where the last element
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
index 95d71fad21a34..ab83e538e4996 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/fold.bench.cpp
@@ -50,11 +50,7 @@ int main(int argc, char** argv) {
ValueType init = c.back();
c.pop_back();
- auto f = [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x + y;
- };
+ auto f = [](auto x, auto y) { return x + y; };
for ([[maybe_unused]] auto _ : st) {
benchmark::DoNotOptimize(c);
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
index 000117f1aac65..5ae6ca06c6c8c 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/is_permutation.bench.cpp
@@ -27,18 +27,10 @@ int main(int argc, char** argv) {
return std::is_permutation(first1, last1, first2, last2);
};
auto std_is_permutation_3leg_pred = [](auto first1, auto last1, auto first2, auto) {
- return std::is_permutation(first1, last1, first2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::is_permutation(first1, last1, first2, [](auto x, auto y) { return x == y; });
};
auto std_is_permutation_4leg_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::is_permutation(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::is_permutation(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
auto register_benchmarks = [&](auto bm, std::string comment) {
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
index 37374ef7aadca..c9411620b20fa 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/mismatch.bench.cpp
@@ -26,18 +26,10 @@ int main(int argc, char** argv) {
return std::mismatch(first1, last1, first2, last2);
};
auto std_mismatch_3leg_pred = [](auto first1, auto last1, auto first2, auto) {
- return std::mismatch(first1, last1, first2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::mismatch(first1, last1, first2, [](auto x, auto y) { return x == y; });
};
auto std_mismatch_4leg_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::mismatch(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::mismatch(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
// Benchmark {std,ranges}::mismatch where we find the mismatching element at the very end (worst case).
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
index 3d25105238164..06b3354169cf1 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/search.bench.cpp
@@ -24,11 +24,7 @@ int main(int argc, char** argv) {
return std::search(first1, last1, first2, last2);
};
auto std_search_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::search(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::search(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
// Benchmark {std,ranges}::search where the needle is never found (worst case).
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
index 212aabfd7cdb3..d00c3cf1e6ea1 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/search_n.bench.cpp
@@ -24,11 +24,7 @@ int main(int argc, char** argv) {
return std::search_n(first, last, n, value);
};
auto std_search_n_pred = [](auto first, auto last, auto n, auto const& value) {
- return std::search_n(first, last, n, value, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::search_n(first, last, n, value, [](auto x, auto y) { return x == y; });
};
// Benchmark {std,ranges}::search_n where the needle almost matches a lot.
diff --git a/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp b/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
index 2950ad5322e84..57747e551dc71 100644
--- a/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/nonmodifying/starts_with.bench.cpp
@@ -20,11 +20,7 @@
int main(int argc, char** argv) {
auto ranges_starts_with_pred = [](auto first1, auto last1, auto first2, auto last2) {
- return std::ranges::starts_with(first1, last1, first2, last2, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x == y;
- });
+ return std::ranges::starts_with(first1, last1, first2, last2, [](auto x, auto y) { return x == y; });
};
// Benchmark ranges::starts_with where we find the mismatching element at the very end (worst case).
diff --git a/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
index ac25826acb085..884df63b151f6 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/is_sorted.bench.cpp
@@ -22,11 +22,7 @@
int main(int argc, char** argv) {
auto std_is_sorted = [](auto first, auto last) { return std::is_sorted(first, last); };
auto std_is_sorted_pred = [](auto first, auto last) {
- return std::is_sorted(first, last, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x < y;
- });
+ return std::is_sorted(first, last, [](auto x, auto y) { return x < y; });
};
// Benchmark {std,ranges}::is_sorted on a sorted sequence (the worst case).
diff --git a/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp b/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
index 9687416b39c29..05b3a3966f383 100644
--- a/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
+++ b/libcxx/test/benchmarks/algorithms/sorting/is_sorted_until.bench.cpp
@@ -22,11 +22,7 @@
int main(int argc, char** argv) {
auto std_is_sorted_until = [](auto first, auto last) { return std::is_sorted_until(first, last); };
auto std_is_sorted_until_pred = [](auto first, auto last) {
- return std::is_sorted_until(first, last, [](auto x, auto y) {
- benchmark::DoNotOptimize(x);
- benchmark::DoNotOptimize(y);
- return x < y;
- });
+ return std::is_sorted_until(first, last, [](auto x, auto y) { return x < y; });
};
// Benchmark {std,ranges}::is_sorted_until on a sorted sequence (the worst case).
More information about the libcxx-commits
mailing list