#include "data/HashMap.h" #include "data/ProbingHashMap.h" #include "test/Test.h" #include "utils/Clock.h" template static void test(const Map& m) { Core::Clock::Nanos nanos = 0; CORE_TEST_ERROR(Core::Clock::getNanos(nanos)); int sum = 0; for(int i = 0; i < 10000; i++) { for(int k = -5000; k < 5000; k++) { const int* s = m.search(i + k); if(s != nullptr) { sum += *s; } } } Core::Clock::Nanos nanos2 = 0; CORE_TEST_ERROR(Core::Clock::getNanos(nanos2)); CORE_LOG_INFO("# | # ns", sum, nanos2 - nanos); } int main() { Core::HashMap m; Core::ProbingHashMap m2(1 << 30); for(int i = 0; i < 10000; i++) { CORE_TEST_ERROR(m.add(i, i * i)); CORE_TEST_ERROR(m2.add(i, i * i)); } test(m); test(m); test(m); test(m2); test(m2); test(m2); return 0; }