From cebfc5c8facbf6ae335499f7f4b3dc57a60af999 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 29 Sep 2024 19:03:55 +0300 Subject: TDLIB update up to the current state --- .../tdlib/td/tdutils/test/ConcurrentHashMap.cpp | 38 ++++++++++------------ 1 file changed, 18 insertions(+), 20 deletions(-) (limited to 'protocols/Telegram/tdlib/td/tdutils/test/ConcurrentHashMap.cpp') 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 key{KeyT{}}; - std::atomic 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 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((i + 1) * MUL % n_) + 3; - auto y = td::narrow_cast(i + 2); - hash_map->insert(x, y); - } - }); - } - for (auto &thread : threads) { - thread.join(); + for (int count = 0; count < 1000; count++) { + td::vector 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((i + 1) * MUL % n_) + 3; + auto y = td::narrow_cast(i + 2); + hash_map->insert(x, y); + } + }); + } + for (auto &thread : threads) { + thread.join(); + } } } -- cgit v1.2.3