summaryrefslogtreecommitdiff
path: root/protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp')
-rw-r--r--protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp38
1 files changed, 18 insertions, 20 deletions
diff --git a/protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp b/protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp
index 5ab1f85ad2..7fbe25d0d7 100644
--- a/protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp
+++ b/protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp
@@ -1,5 +1,5 @@
//
-// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2023
+// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -40,10 +40,6 @@ class ArrayHashMap {
public:
explicit ArrayHashMap(std::size_t n) : array_(n) {
}
- struct Node {
- std::atomic<KeyT> key{KeyT{}};
- std::atomic<ValueT> value{ValueT{}};
- };
static td::string get_name() {
return "ArrayHashMap";
}
@@ -201,21 +197,23 @@ class HashMapBenchmark final : public td::Benchmark {
void run(int n) final {
n = n_;
- td::vector<td::thread> threads;
-
- for (std::size_t i = 0; i < threads_n; i++) {
- std::size_t l = n * i / threads_n;
- std::size_t r = n * (i + 1) / threads_n;
- threads.emplace_back([l, r, this] {
- for (size_t i = l; i < r; i++) {
- auto x = td::narrow_cast<int>((i + 1) * MUL % n_) + 3;
- auto y = td::narrow_cast<int>(i + 2);
- hash_map->insert(x, y);
- }
- });
- }
- for (auto &thread : threads) {
- thread.join();
+ for (int count = 0; count < 1000; count++) {
+ td::vector<td::thread> threads;
+
+ for (std::size_t i = 0; i < threads_n; i++) {
+ std::size_t l = n * i / threads_n;
+ std::size_t r = n * (i + 1) / threads_n;
+ threads.emplace_back([l, r, this] {
+ for (size_t i = l; i < r; i++) {
+ auto x = td::narrow_cast<int>((i + 1) * MUL % n_) + 3;
+ auto y = td::narrow_cast<int>(i + 2);
+ hash_map->insert(x, y);
+ }
+ });
+ }
+ for (auto &thread : threads) {
+ thread.join();
+ }
}
}