diff options
| author | levlam <levlam@telegram.org> | 2022-11-23 19:37:32 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2022-11-23 19:37:32 +0300 |
| commit | af05db3f15fd36932b64e270a7663a8ba34d065e (patch) | |
| tree | 673cb43a0e58dafc85260b096954a4a56f837aa0 /benchmark | |
| parent | b1ddf9d3a7c739b9cdfdfe55fa34c6d2ccbadab5 (diff) | |
Add td::Hash and use it everywhere instead of unusable std::hash.
Diffstat (limited to 'benchmark')
| -rw-r--r-- | benchmark/hashmap_build.cpp | 26 | ||||
| -rw-r--r-- | benchmark/hashset_memory.cpp | 11 |
2 files changed, 19 insertions, 18 deletions
diff --git a/benchmark/hashmap_build.cpp b/benchmark/hashmap_build.cpp index 7d63acb71..f6e71b748 100644 --- a/benchmark/hashmap_build.cpp +++ b/benchmark/hashmap_build.cpp @@ -25,19 +25,19 @@ //#define CREATE_MAP(num) CREATE_MAP_IMPL(num) #define CREATE_MAP(num) -#define CREATE_MAP_IMPL(num) \ - int f_##num() { \ - test_map<int, std::array<char, num>> m; \ - m.emplace(1, std::array<char, num>{}); \ - int sum = 0; \ - for (auto &it : m) { \ - sum += it.first; \ - } \ - auto it = m.find(1); \ - sum += it->first; \ - m.erase(it); \ - return sum; \ - } \ +#define CREATE_MAP_IMPL(num) \ + int f_##num() { \ + test_map<td::int32, std::array<char, num>> m; \ + m.emplace(1, std::array<char, num>{}); \ + int sum = 0; \ + for (auto &it : m) { \ + sum += it.first; \ + } \ + auto it = m.find(1); \ + sum += it->first; \ + m.erase(it); \ + return sum; \ + } \ int x_##num = f_##num() CREATE_MAP(__LINE__); diff --git a/benchmark/hashset_memory.cpp b/benchmark/hashset_memory.cpp index ec2ba858e..8f31b5211 100644 --- a/benchmark/hashset_memory.cpp +++ b/benchmark/hashset_memory.cpp @@ -12,6 +12,7 @@ #include "td/utils/FlatHashMap.h" #include "td/utils/FlatHashMapChunks.h" #include "td/utils/FlatHashTable.h" +#include "td/utils/HashTableUtils.h" #include "td/utils/logging.h" #include "td/utils/MapNode.h" #include "td/utils/misc.h" @@ -77,9 +78,9 @@ class IntGenerator { }; template <> -class Generator<td::uint32> final : public IntGenerator<td::uint32> {}; +class Generator<td::int32> final : public IntGenerator<td::int32> {}; template <> -class Generator<td::uint64> final : public IntGenerator<td::uint64> {}; +class Generator<td::int64> final : public IntGenerator<td::int64> {}; template <class T> class Generator<td::unique_ptr<T>> { @@ -159,14 +160,14 @@ void print_memory_stats(td::Slice name) { td::string big_buff(1 << 16, '\0'); td::StringBuilder sb(big_buff, false); #define MEASURE(KeyT, ValueT) measure<T<KeyT, ValueT>, KeyT, ValueT>(sb, name, #KeyT, #ValueT); - MEASURE(td::uint32, td::uint32); - MEASURE(td::uint64, td::unique_ptr<Bytes<360>>); + MEASURE(td::int32, td::int32); + MEASURE(td::int64, td::unique_ptr<Bytes<360>>); if (!sb.as_cslice().empty()) { LOG(PLAIN) << '\n' << sb.as_cslice() << '\n'; } } -template <class KeyT, class ValueT, class HashT = std::hash<KeyT>, class EqT = std::equal_to<KeyT>> +template <class KeyT, class ValueT, class HashT = td::Hash<KeyT>, class EqT = std::equal_to<KeyT>> using FlatHashMapImpl = td::FlatHashTable<td::MapNode<KeyT, ValueT>, HashT, EqT>; #define FOR_EACH_TABLE(F) \ |
