aboutsummaryrefslogtreecommitdiffhomepage
path: root/benchmark/bench_misc.cpp
diff options
context:
space:
mode:
authorlevlam <levlam@telegram.org>2023-10-22 01:10:28 +0300
committerlevlam <levlam@telegram.org>2023-10-22 01:10:28 +0300
commit87aff1320be24463b2584ed872ef66bc10d97a05 (patch)
tree27306979a944ef400e9efcdbda23f7f46368321b /benchmark/bench_misc.cpp
parent605a3af4b2580bc6d811add7a8a1ac2ddfc1acf9 (diff)
Add any_of benchmark.
Diffstat (limited to 'benchmark/bench_misc.cpp')
-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());