8#include <gtest/gtest.h>
10#include "arcane/utils/HashTableMap.h"
11#include "arcane/utils/String.h"
12#include "arcane/utils/PlatformUtils.h"
13#include "arcane/utils/HashTableMap2.h"
16#include <unordered_map>
38 hash1.add(25,
"Test1");
42 hash1.add(32,
"Test2");
45 hash1.add(32,
"Test3");
58 hash1.add(32,
"Test4");
68 for (
int i = 0; i < n; ++i)
69 hash2.add((i + 1), (i + 1) * 10);
75 for (
int i = 0; i <
n2; ++i)
76 hash2.add((i + 1), (i + 1) * 10);
79 hash2.resize(3000,
true);
81 for (
int i = 0; i <
n2; ++i)
86 for (
int i = 0; i <
n2; ++i)
92 for (
int i = 0; i <
n2; ++i)
98 std::cout <<
"Test Hash n=" <<
nx <<
"\n";
99 for (
int i = 0; i <
nx; ++i)
100 hash2.add((i + 1), (i + 1) * 5);
101 std::cout <<
"MEM=" << platform::getMemoryUsed() <<
"\n";
106Int64 _getRealTimeUS()
108 auto x = std::chrono::high_resolution_clock::now();
110 auto y = std::chrono::time_point_cast<std::chrono::microseconds>(x);
111 return static_cast<Int64>(y.time_since_epoch().count());
114template <
typename Key,
typename Value>
120 using value_type = std::pair<Key, Value>;
130 void insert(std::pair<Key, Value> v)
132 m_map.add(v.first, v.second);
134 void clear() { m_map.clear(); }
135 const Data* end()
const {
return nullptr; }
136 const Data* find(
const Key&
k)
const
138 return m_map.lookup(
k);
140 void erase(
const Data* d)
143 Data*
dd =
const_cast<Data*
>(d);
148 size_t size()
const {
return m_map.count(); }
149 template <
typename Lambda>
void eachValue(
const Lambda& v)
159template <
bool HasIter,
typename HashType>
void
162 using value_type =
typename HashType::value_type;
163 std::cout <<
"ADD_MULTIPLE name=" << name <<
"\n";
167 Int64 t0 = _getRealTimeUS();
169 Int32 value = (i + 1) * 5;
172 Int64 t1 = _getRealTimeUS();
173 std::cout <<
"ADD_TIME=" << (t1 - t0) <<
"\n";
183 std::cout <<
"FIND_TIME=" << (
t2 - t1) <<
" nb_found=" <<
nb_found <<
"\n";
202 std::cout <<
"ITER_TIME=" << (
t3 -
t2) <<
" total=" << total <<
" T2=" <<
expected_total <<
"\n";
214 std::cout <<
"ERASE_TIME=" << (
t6 -
t5) <<
" remaining_size=" <<
map_instance.size() <<
"\n";
216 std::cout <<
"MEM (MB)=" <<
static_cast<Int64>(platform::getMemoryUsed() / 1000000.0) <<
"\n";
219int num_keys = 100000;
223 std::unordered_map<Int64, Int32>
std_map;
#define ASSERT_FALSE(condition)
Vérifie que condition est faux.
#define ASSERT_TRUE(condition)
Vérifie que condition est vrai.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Implementation of std::unordered_map.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-