From 4eb77e6628a807174113b6ac9b2b63fd4290b093 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 22 Aug 2017 00:59:27 +0300 Subject: [PATCH] Updated test of string hashes [#CLICKHOUSE-3244]. --- .../Interpreters/tests/hash_map_string_2.cpp | 20 ++++----- .../Interpreters/tests/hash_map_string_3.cpp | 41 ++++++++++++++----- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/dbms/src/Interpreters/tests/hash_map_string_2.cpp b/dbms/src/Interpreters/tests/hash_map_string_2.cpp index 4fb21fae998..3958592e3d5 100644 --- a/dbms/src/Interpreters/tests/hash_map_string_2.cpp +++ b/dbms/src/Interpreters/tests/hash_map_string_2.cpp @@ -636,20 +636,20 @@ int main(int argc, char ** argv) } if (!m || m == 1) bench (data, "StringRef_Compare1_Ptrs"); - if (!m || m == 2) bench (data, "StringRef_Compare1_Index"); + if (!m || m == 2) bench (data, "StringRef_Compare1_Index"); if (!m || m == 3) bench (data, "StringRef_CompareMemcmp"); - if (!m || m == 4) bench (data, "StringRef_Compare8_1_byUInt64"); - if (!m || m == 5) bench (data, "StringRef_Compare16_1_byMemcmp"); + if (!m || m == 4) bench (data, "StringRef_Compare8_1_byUInt64"); + if (!m || m == 5) bench (data, "StringRef_Compare16_1_byMemcmp"); if (!m || m == 6) bench(data, "StringRef_Compare16_1_byUInt64_logicAnd"); - if (!m || m == 7) bench (data, "StringRef_Compare16_1_byUInt64_bitAnd"); + if (!m || m == 7) bench (data, "StringRef_Compare16_1_byUInt64_bitAnd"); #if __SSE4_1__ - if (!m || m == 8) bench (data, "StringRef_Compare16_1_byIntSSE"); - if (!m || m == 9) bench (data, "StringRef_Compare16_1_byFloatSSE"); - if (!m || m == 10) bench (data, "StringRef_Compare16_1_bySSE4"); - if (!m || m == 11) bench (data, "StringRef_Compare16_1_bySSE4_wide"); - if (!m || m == 12) bench (data, "StringRef_Compare16_1_bySSE_wide"); + if (!m || m == 8) bench (data, "StringRef_Compare16_1_byIntSSE"); + if (!m || m == 9) bench (data, "StringRef_Compare16_1_byFloatSSE"); + if (!m || m == 10) bench (data, "StringRef_Compare16_1_bySSE4"); + if (!m || m == 11) bench (data, "StringRef_Compare16_1_bySSE4_wide"); + if (!m || m == 12) bench (data, "StringRef_Compare16_1_bySSE_wide"); #endif - if (!m || m == 100) bench (data, "StringRef_CompareAlwaysTrue"); + if (!m || m == 100) bench (data, "StringRef_CompareAlwaysTrue"); if (!m || m == 101) bench (data, "StringRef_CompareAlmostAlwaysTrue"); /// 10 > 8, 9 diff --git a/dbms/src/Interpreters/tests/hash_map_string_3.cpp b/dbms/src/Interpreters/tests/hash_map_string_3.cpp index dfebabdcbbf..7176b47fc4d 100644 --- a/dbms/src/Interpreters/tests/hash_map_string_3.cpp +++ b/dbms/src/Interpreters/tests/hash_map_string_3.cpp @@ -139,6 +139,26 @@ struct FastHash64 }; +struct FNV1a +{ + size_t operator() (StringRef x) const + { + size_t res = 0xcbf29ce484222325ULL; + + const char * pos = x.data; + const char * end = x.data + x.size; + + for (; pos < end; ++pos) + { + res *= 1099511628211ULL; + res ^= *pos; + } + + return res; + } +}; + + #if __SSE4_1__ struct CrapWow @@ -462,20 +482,21 @@ int main(int argc, char ** argv) << std::endl; } - if (!m || m == 1) bench(data, "StringRef_CityHash64"); - if (!m || m == 2) bench (data, "StringRef_FastHash64"); - if (!m || m == 3) bench (data, "StringRef_SimpleHash"); + if (!m || m == 1) bench(data, "StringRef_CityHash64"); + if (!m || m == 2) bench (data, "StringRef_FastHash64"); + if (!m || m == 3) bench (data, "StringRef_SimpleHash"); + if (!m || m == 3) bench (data, "StringRef_FNV1a"); #if __SSE4_1__ - if (!m || m == 4) bench (data, "StringRef_CrapWow"); - if (!m || m == 5) bench (data, "StringRef_CRC32Hash"); - if (!m || m == 6) bench (data, "StringRef_CRC32ILPHash"); + if (!m || m == 4) bench (data, "StringRef_CrapWow"); + if (!m || m == 5) bench (data, "StringRef_CRC32Hash"); + if (!m || m == 6) bench (data, "StringRef_CRC32ILPHash"); #endif - if (!m || m == 7) bench(data, "StringRef_VerySimpleHash"); - if (!m || m == 8) bench(data, "StringRef_FarmHash64"); - if (!m || m == 9) bench>(data, "StringRef_MetroHash64_1"); - if (!m || m == 10) bench>(data, "StringRef_MetroHash64_2"); + if (!m || m == 7) bench (data, "StringRef_VerySimpleHash"); + if (!m || m == 8) bench (data, "StringRef_FarmHash64"); + if (!m || m == 9) bench>(data, "StringRef_MetroHash64_1"); + if (!m || m == 10) bench>(data, "StringRef_MetroHash64_2"); return 0; }