Add mulxp1_hash32 to benchmarks

This commit is contained in:
Peter Dimov
2022-12-08 17:57:00 +02:00
parent cf87e304f6
commit ceb8303601
3 changed files with 57 additions and 0 deletions

View File

@@ -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<mulxp1_hash_>( N * 16, v );
test_hash_speed<mulxp2_hash_>( N * 16, v );
test_hash_speed<mulxp3_hash_>( N * 16, v );
test_hash_speed<mulxp1_hash32_>( N * 16, v );
test_hash_speed<mulxp3_hash32_>( N * 16, v );
#endif
@@ -432,6 +441,7 @@ int main()
test_hash_collision<mulxp1_hash_>( N * 16, v, n );
test_hash_collision<mulxp2_hash_>( N * 16, v, n );
test_hash_collision<mulxp3_hash_>( N * 16, v, n );
test_hash_collision<mulxp1_hash32_>( N * 16, v, n );
test_hash_collision<mulxp3_hash32_>( N * 16, v, n );
#endif
}
@@ -459,6 +469,7 @@ int main()
test_container_speed<K, mulxp1_hash_>( N, v );
test_container_speed<K, mulxp2_hash_>( N, v );
test_container_speed<K, mulxp3_hash_>( N, v );
test_container_speed<K, mulxp1_hash32_>( N, v );
test_container_speed<K, mulxp3_hash32_>( N, v );
#endif

View File

@@ -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

View File

@@ -41,8 +41,16 @@ static std::vector<std::string> 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