diff --git a/benchmark/unordered.cpp b/benchmark/unordered.cpp index b7e2a80..6550adf 100644 --- a/benchmark/unordered.cpp +++ b/benchmark/unordered.cpp @@ -96,7 +96,11 @@ struct mul31_x8_hash char const * p = st.data(); std::size_t n = st.size(); +#if SIZE_MAX > UINT32_MAX boost::uint64_t h = 0xCBF29CE484222325ull; +#else + boost::uint64_t h = 0x811C9DC5u; +#endif while( n >= 8 ) { @@ -206,6 +210,14 @@ struct mulxp3_hash_ } }; +struct mulxp3_hash32_ +{ + std::size_t operator()( std::string const& st ) const BOOST_NOEXCEPT + { + return mulxp3_hash32( (unsigned char const*)st.data(), st.size(), 0 ); + } +}; + #endif // test_hash_speed @@ -376,6 +388,7 @@ int main() test_hash_speed( N * 16, v ); test_hash_speed( N * 16, v ); test_hash_speed( N * 16, v ); + test_hash_speed( N * 16, v ); #endif std::puts( "" ); @@ -410,6 +423,7 @@ int main() test_hash_collision( N * 16, v, n ); test_hash_collision( N * 16, v, n ); test_hash_collision( N * 16, v, n ); + test_hash_collision( N * 16, v, n ); #endif } @@ -433,6 +447,7 @@ int main() test_container_speed( N, v ); test_container_speed( N, v ); test_container_speed( N, v ); + test_container_speed( N, v ); #endif std::puts( "" ); diff --git a/benchmark/unordered_flat.cpp b/benchmark/unordered_flat.cpp index 395279a..340c52b 100644 --- a/benchmark/unordered_flat.cpp +++ b/benchmark/unordered_flat.cpp @@ -288,7 +288,11 @@ struct mul31_x8_hash char const * p = st.data(); std::size_t n = st.size(); +#if SIZE_MAX > UINT32_MAX boost::uint64_t h = 0xCBF29CE484222325ull; +#else + boost::uint64_t h = 0x811C9DC5u; +#endif while( n >= 8 ) { @@ -427,6 +431,24 @@ struct mulxp3_hash_ } }; +struct mulxp3_hash32_ +{ + using is_avalanching = void; + + std::size_t operator()( std::string_view const& st ) const BOOST_NOEXCEPT + { + std::size_t r = mulxp3_hash32( (unsigned char const*)st.data(), st.size(), 0 ); + +#if SIZE_MAX > UINT32_MAX + + r |= r << 32; + +#endif + + return r; + } +}; + #endif // @@ -454,6 +476,7 @@ int main() test< mulxp1_hash_ >( "mulxp1_hash" ); test< mulxp2_hash_ >( "mulxp2_hash" ); test< mulxp3_hash_ >( "mulxp3_hash" ); + test< mulxp3_hash32_ >( "mulxp3_hash32" ); #endif diff --git a/benchmark/word_count.cpp b/benchmark/word_count.cpp index 2f09f04..566330e 100644 --- a/benchmark/word_count.cpp +++ b/benchmark/word_count.cpp @@ -215,7 +215,11 @@ struct mul31_x8_hash char const * p = st.data(); std::size_t n = st.size(); +#if SIZE_MAX > UINT32_MAX boost::uint64_t h = 0xCBF29CE484222325ull; +#else + boost::uint64_t h = 0x811C9DC5u; +#endif while( n >= 8 ) { @@ -352,6 +356,24 @@ struct mulxp3_hash_ } }; +struct mulxp3_hash32_ +{ + using is_avalanching = void; + + std::size_t operator()( std::string_view const& st ) const BOOST_NOEXCEPT + { + std::size_t r = mulxp3_hash32( (unsigned char const*)st.data(), st.size(), 0 ); + +#if SIZE_MAX > UINT32_MAX + + r |= r << 32; + +#endif + + return r; + } +}; + #endif // @@ -379,6 +401,7 @@ int main() test< mulxp1_hash_ >( "mulxp1_hash" ); test< mulxp2_hash_ >( "mulxp2_hash" ); test< mulxp3_hash_ >( "mulxp3_hash" ); + test< mulxp3_hash32_ >( "mulxp3_hash32" ); #endif