From ceb8303601bcc39a0a4e92ff14202ea586241575 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 8 Dec 2022 17:57:00 +0200 Subject: [PATCH] Add mulxp1_hash32 to benchmarks --- benchmark/unordered.cpp | 11 +++++++++++ benchmark/unordered_flat.cpp | 19 +++++++++++++++++++ benchmark/word_count.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/benchmark/unordered.cpp b/benchmark/unordered.cpp index 232e71c..d733b83 100644 --- a/benchmark/unordered.cpp +++ b/benchmark/unordered.cpp @@ -213,6 +213,14 @@ struct mulxp3_hash_ } }; +struct mulxp1_hash32_ +{ + std::size_t operator()( std::string const& st ) const BOOST_NOEXCEPT + { + return mulxp1_hash32( (unsigned char const*)st.data(), st.size(), 0 ); + } +}; + struct mulxp3_hash32_ { std::size_t operator()( std::string const& st ) const BOOST_NOEXCEPT @@ -394,6 +402,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 ); test_hash_speed( N * 16, v ); #endif @@ -432,6 +441,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 ); test_hash_collision( N * 16, v, n ); #endif } @@ -459,6 +469,7 @@ int main() test_container_speed( N, v ); test_container_speed( N, v ); test_container_speed( N, v ); + test_container_speed( N, v ); test_container_speed( N, v ); #endif diff --git a/benchmark/unordered_flat.cpp b/benchmark/unordered_flat.cpp index 8286783..061e698 100644 --- a/benchmark/unordered_flat.cpp +++ b/benchmark/unordered_flat.cpp @@ -302,6 +302,24 @@ struct mulxp3_hash_ } }; +struct mulxp1_hash32_ +{ + using is_avalanching = void; + + std::size_t operator()( std::string const& st ) const BOOST_NOEXCEPT + { + std::size_t r = mulxp1_hash32( (unsigned char const*)st.data(), st.size(), 0 ); + +#if SIZE_MAX > UINT32_MAX + + r |= r << 32; + +#endif + + return r; + } +}; + struct mulxp3_hash32_ { using is_avalanching = void; @@ -348,6 +366,7 @@ int main() test< mulxp1_hash_ >( "mulxp1_hash" ); test< mulxp3_hash_ >( "mulxp3_hash" ); + test< mulxp1_hash32_ >( "mulxp1_hash32" ); test< mulxp3_hash32_ >( "mulxp3_hash32" ); #endif diff --git a/benchmark/word_count.cpp b/benchmark/word_count.cpp index c03fb9c..0bfcf3f 100644 --- a/benchmark/word_count.cpp +++ b/benchmark/word_count.cpp @@ -41,8 +41,16 @@ static std::vector words; static void init_words() { +#if SIZE_MAX > UINT32_MAX + char const* fn = "enwik9"; // http://mattmahoney.net/dc/textdata +#else + + char const* fn = "enwik8"; // ditto + +#endif + auto t1 = std::chrono::steady_clock::now(); std::ifstream is( fn ); @@ -245,6 +253,24 @@ struct mulxp3_hash32_ } }; +struct mulxp1_hash32_ +{ + using is_avalanching = void; + + std::size_t operator()( std::string_view const& st ) const BOOST_NOEXCEPT + { + std::size_t r = mulxp1_hash32( (unsigned char const*)st.data(), st.size(), 0 ); + +#if SIZE_MAX > UINT32_MAX + + r |= r << 32; + +#endif + + return r; + } +}; + #endif // @@ -273,6 +299,7 @@ int main() test< mulxp1_hash_ >( "mulxp1_hash" ); test< mulxp3_hash_ >( "mulxp3_hash" ); + test< mulxp1_hash32_ >( "mulxp1_hash32" ); test< mulxp3_hash32_ >( "mulxp3_hash32" ); #endif