diff options
author | George Hazan <george.hazan@gmail.com> | 2024-09-29 19:03:55 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-09-29 19:04:03 +0300 |
commit | cebfc5c8facbf6ae335499f7f4b3dc57a60af999 (patch) | |
tree | 4c39e613c87f6164df1fe80601e611987aaaec84 /protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp | |
parent | 189164bebda4bca9bb3d672500d844bfe7f26517 (diff) |
TDLIB update up to the current state
Diffstat (limited to 'protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp')
-rw-r--r-- | protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp | 38 |
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(); + } } } |