forked from boostorg/container_hash
Add old_boost_hash to benchmark/unordered.cpp
This commit is contained in:
@@ -163,6 +163,28 @@ template<> struct fnv1a_hash_impl<64>
|
|||||||
|
|
||||||
struct fnv1a_hash: fnv1a_hash_impl< std::numeric_limits<std::size_t>::digits > {};
|
struct fnv1a_hash: fnv1a_hash_impl< std::numeric_limits<std::size_t>::digits > {};
|
||||||
|
|
||||||
|
// old_boost_hash
|
||||||
|
|
||||||
|
class old_boost_hash
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
std::size_t operator()( std::string const& st ) const BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
char const * p = st.data();
|
||||||
|
std::size_t n = st.size();
|
||||||
|
|
||||||
|
std::size_t h = 0;
|
||||||
|
|
||||||
|
for( std::size_t i = 0; i < n; ++i )
|
||||||
|
{
|
||||||
|
h ^= static_cast<unsigned char>( p[i] ) + 0x9e3779b9 + ( h << 6 ) + ( h >> 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
template<class V, class S> void test4( int N, V const& v, char const * hash, S s )
|
template<class V, class S> void test4( int N, V const& v, char const * hash, S s )
|
||||||
@@ -295,6 +317,7 @@ int main()
|
|||||||
test2<mul31_hash>( N * 16, v );
|
test2<mul31_hash>( N * 16, v );
|
||||||
test2<mul31_unrolled_hash>( N * 16, v );
|
test2<mul31_unrolled_hash>( N * 16, v );
|
||||||
test2<fnv1a_hash>( N * 16, v );
|
test2<fnv1a_hash>( N * 16, v );
|
||||||
|
test2<old_boost_hash>( N * 16, v );
|
||||||
test2<boost::hash<std::string> >( N * 16, v );
|
test2<boost::hash<std::string> >( N * 16, v );
|
||||||
test2<std::hash<std::string> >( N * 16, v );
|
test2<std::hash<std::string> >( N * 16, v );
|
||||||
|
|
||||||
@@ -305,6 +328,7 @@ int main()
|
|||||||
test3<K, mul31_hash>( N, v );
|
test3<K, mul31_hash>( N, v );
|
||||||
test3<K, mul31_unrolled_hash>( N, v );
|
test3<K, mul31_unrolled_hash>( N, v );
|
||||||
test3<K, fnv1a_hash>( N, v );
|
test3<K, fnv1a_hash>( N, v );
|
||||||
|
test3<K, old_boost_hash>( N, v );
|
||||||
test3<K, boost::hash<std::string> >( N, v );
|
test3<K, boost::hash<std::string> >( N, v );
|
||||||
test3<K, std::hash<std::string> >( N, v );
|
test3<K, std::hash<std::string> >( N, v );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user