aboutsummaryrefslogtreecommitdiffhomepage
path: root/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'benchmark')
-rw-r--r--benchmark/bench_misc.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/benchmark/bench_misc.cpp b/benchmark/bench_misc.cpp
index 7d4c9aa73..5ef9cd4b4 100644
--- a/benchmark/bench_misc.cpp
+++ b/benchmark/bench_misc.cpp
@@ -726,9 +726,38 @@ BENCH(AddToTopTd, "add_to_top td") {
}
}
+BENCH(AnyOfStd, "any_of std") {
+ td::vector<int> v;
+ for (int i = 0; i < 100; i++) {
+ v.push_back(i);
+ }
+ int res = 0;
+ for (int i = 0; i < n; i++) {
+ int rem = td::Random::fast(0, 127);
+ res += static_cast<int>(std::any_of(v.begin(), v.end(), [rem](int x) { return (x & 127) == rem; }));
+ }
+ td::do_not_optimize_away(res);
+}
+
+BENCH(AnyOfTd, "any_of td") {
+ td::vector<int> v;
+ for (int i = 0; i < 100; i++) {
+ v.push_back(i);
+ }
+ int res = 0;
+ for (int i = 0; i < n; i++) {
+ int rem = td::Random::fast(0, 127);
+ res += static_cast<int>(td::any_of(v, [rem](int x) { return (x & 127) == rem; }));
+ }
+ td::do_not_optimize_away(res);
+}
+
int main() {
SET_VERBOSITY_LEVEL(VERBOSITY_NAME(DEBUG));
+ td::bench(AnyOfStdBench());
+ td::bench(AnyOfTdBench());
+
td::bench(ToStringIntSmallBench());
td::bench(ToStringIntBigBench());