Skip to content

Commit

Permalink
Remove Murmur3 and Spooky2
Browse files Browse the repository at this point in the history
  • Loading branch information
pdimov committed Jul 16, 2024
1 parent fb66e1e commit 3501a6b
Show file tree
Hide file tree
Showing 14 changed files with 9 additions and 302 deletions.
5 changes: 0 additions & 5 deletions benchmark/average.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
#include <boost/hash2/fnv1a.hpp>
#include <boost/hash2/siphash.hpp>
#include <boost/hash2/xxhash.hpp>
#include <boost/hash2/spooky2.hpp>
#include <boost/hash2/md5.hpp>
#include <boost/hash2/sha1.hpp>
#include <boost/hash2/murmur3.hpp>
#include <boost/hash2/hash_append.hpp>
#include <boost/hash2/get_integral_result.hpp>
#include <boost/core/type_name.hpp>
Expand Down Expand Up @@ -57,11 +55,8 @@ template<class R> void test( int N )

test_<R, boost::hash2::fnv1a_32>( N );
test_<R, boost::hash2::fnv1a_64>( N );
test_<R, boost::hash2::murmur3_32>( N );
test_<R, boost::hash2::murmur3_128>( N );
test_<R, boost::hash2::xxhash_32>( N );
test_<R, boost::hash2::xxhash_64>( N );
test_<R, boost::hash2::spooky2_128>( N );
test_<R, boost::hash2::siphash_32>( N );
test_<R, boost::hash2::siphash_64>( N );
test_<R, boost::hash2::md5_128>( N );
Expand Down
5 changes: 0 additions & 5 deletions benchmark/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <boost/hash2/fnv1a.hpp>
#include <boost/hash2/siphash.hpp>
#include <boost/hash2/xxhash.hpp>
#include <boost/hash2/spooky2.hpp>
#include <boost/hash2/murmur3.hpp>
#include <boost/hash2/md5.hpp>
#include <boost/hash2/sha1.hpp>
#include <boost/hash2/hash_append.hpp>
Expand Down Expand Up @@ -46,11 +44,8 @@ void test( int N, int M )
{
test_<boost::hash2::fnv1a_32>( data, N, M );
test_<boost::hash2::fnv1a_64>( data, N, M );
test_<boost::hash2::murmur3_32>( data, N, M );
test_<boost::hash2::murmur3_128>( data, N, M );
test_<boost::hash2::xxhash_32>( data, N, M );
test_<boost::hash2::xxhash_64>( data, N, M );
test_<boost::hash2::spooky2_128>( data, N, M );
test_<boost::hash2::siphash_32>( data, N, M );
test_<boost::hash2::siphash_64>( data, N, M );
test_<boost::hash2::md5_128>( data, N, M );
Expand Down
133 changes: 0 additions & 133 deletions benchmark/keys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#include <boost/hash2/fnv1a.hpp>
#include <boost/hash2/siphash.hpp>
#include <boost/hash2/xxhash.hpp>
#include <boost/hash2/spooky2.hpp>
#include <boost/hash2/md5.hpp>
#include <boost/hash2/sha1.hpp>
#include <boost/hash2/murmur3.hpp>
#include <boost/hash2/hash_append.hpp>
#include <boost/hash2/get_integral_result.hpp>
#include <boost/core/type_name.hpp>
Expand All @@ -25,132 +23,6 @@

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

class mul31_32
{
private:

std::uint32_t st_;

public:

typedef std::uint32_t result_type;
typedef std::uint32_t size_type;

mul31_32(): st_( 0x811C9DC5ul )
{
}

explicit mul31_32( std::uint64_t seed ): st_( 0x811C9DC5ul ^ ( seed & 0xFFFFFFFFu ) ^ ( seed >> 32 ) )
{
}

void update( void const * pv, std::size_t n )
{
unsigned char const* p = static_cast<unsigned char const*>( pv );

std::uint32_t h = st_;

#if 0

for( std::size_t i = 0; i < n; ++i )
{
h = h * 31 + static_cast<std::uint32_t>( p[i] );
}

#else

while( n >= 4 )
{
h = h * (31u * 31u * 31u * 31u) + p[0] * (31u * 31u * 31u) + p[1] * (31u * 31u) + p[2] * 31u + p[3];

p += 4;
n -= 4;
}

while( n > 0 )
{
h = h * 31u + *p;

++p;
--n;
}

#endif

st_ = h;
}

std::uint32_t result()
{
std::uint32_t r = st_;
st_ = st_ * 31 + 0xFF;
return r;
}
};

class mul31_64
{
private:

std::uint64_t st_;

public:

typedef std::uint64_t result_type;
typedef std::uint64_t size_type;

mul31_64(): st_( 0xCBF29CE484222325ull )
{
}

explicit mul31_64( std::uint64_t seed ): st_( 0xCBF29CE484222325ull ^ seed )
{
}

void update( void const * pv, std::size_t n )
{
unsigned char const* p = static_cast<unsigned char const*>( pv );

std::uint64_t h = st_;

#if 0

for( std::size_t i = 0; i < n; ++i )
{
h = h * 31 + static_cast<std::uint64_t>( p[i] );
}

#else

while( n >= 4 )
{
h = h * (31u * 31u * 31u * 31u) + p[0] * (31u * 31u * 31u) + p[1] * (31u * 31u) + p[2] * 31u + p[3];

p += 4;
n -= 4;
}

while( n > 0 )
{
h = h * 31u + *p;

++p;
--n;
}

#endif

st_ = h;
}

std::uint64_t result()
{
std::uint64_t r = st_;
st_ = st_ * 31 + 0xFF;
return r;
}
};

template<class T, class H> class hasher
{
private:
Expand Down Expand Up @@ -252,15 +124,10 @@ int main()
}
}

test2<mul31_32>( N, v );
test2<mul31_64>( N, v );
test2<boost::hash2::fnv1a_32>( N, v );
test2<boost::hash2::fnv1a_64>( N, v );
test2<boost::hash2::murmur3_32>( N, v );
test2<boost::hash2::murmur3_128>( N, v );
test2<boost::hash2::xxhash_32>( N, v );
test2<boost::hash2::xxhash_64>( N, v );
test2<boost::hash2::spooky2_128>( N, v );
test2<boost::hash2::siphash_32>( N, v );
test2<boost::hash2::siphash_64>( N, v );

Expand Down
133 changes: 0 additions & 133 deletions benchmark/unordered.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#include <boost/hash2/fnv1a.hpp>
#include <boost/hash2/siphash.hpp>
#include <boost/hash2/xxhash.hpp>
#include <boost/hash2/spooky2.hpp>
#include <boost/hash2/md5.hpp>
#include <boost/hash2/sha1.hpp>
#include <boost/hash2/murmur3.hpp>
#include <boost/hash2/hash_append.hpp>
#include <boost/hash2/get_integral_result.hpp>
#include <boost/unordered/unordered_flat_set.hpp>
Expand All @@ -26,132 +24,6 @@

#define STATIC_ASSERT(...) static_assert(__VA_ARGS__, #__VA_ARGS__)

class mul31_32
{
private:

std::uint32_t st_;

public:

typedef std::uint32_t result_type;
typedef std::uint32_t size_type;

mul31_32(): st_( 0x811C9DC5ul )
{
}

explicit mul31_32( std::uint64_t seed ): st_( 0x811C9DC5ul ^ ( seed & 0xFFFFFFFFu ) ^ ( seed >> 32 ) )
{
}

void update( void const * pv, std::size_t n )
{
unsigned char const* p = static_cast<unsigned char const*>( pv );

std::uint32_t h = st_;

#if 0

for( std::size_t i = 0; i < n; ++i )
{
h = h * 31 + static_cast<std::uint32_t>( p[i] );
}

#else

while( n >= 4 )
{
h = h * (31u * 31u * 31u * 31u) + p[0] * (31u * 31u * 31u) + p[1] * (31u * 31u) + p[2] * 31u + p[3];

p += 4;
n -= 4;
}

while( n > 0 )
{
h = h * 31u + *p;

++p;
--n;
}

#endif

st_ = h;
}

std::uint32_t result()
{
std::uint32_t r = st_;
st_ = st_ * 31 + 0xFF;
return r;
}
};

class mul31_64
{
private:

std::uint64_t st_;

public:

typedef std::uint64_t result_type;
typedef std::uint64_t size_type;

mul31_64(): st_( 0xCBF29CE484222325ull )
{
}

explicit mul31_64( std::uint64_t seed ): st_( 0xCBF29CE484222325ull ^ seed )
{
}

void update( void const * pv, std::size_t n )
{
unsigned char const* p = static_cast<unsigned char const*>( pv );

std::uint64_t h = st_;

#if 0

for( std::size_t i = 0; i < n; ++i )
{
h = h * 31 + static_cast<std::uint64_t>( p[i] );
}

#else

while( n >= 4 )
{
h = h * (31u * 31u * 31u * 31u) + p[0] * (31u * 31u * 31u) + p[1] * (31u * 31u) + p[2] * 31u + p[3];

p += 4;
n -= 4;
}

while( n > 0 )
{
h = h * 31u + *p;

++p;
--n;
}

#endif

st_ = h;
}

std::uint64_t result()
{
std::uint64_t r = st_;
st_ = st_ * 31 + 0xFF;
return r;
}
};

template<class T, class H> class hasher
{
private:
Expand Down Expand Up @@ -274,15 +146,10 @@ int main()
std::puts( "" );
}

test2<K, mul31_32>( N, v );
test2<K, mul31_64>( N, v );
test2<K, boost::hash2::fnv1a_32>( N, v );
test2<K, boost::hash2::fnv1a_64>( N, v );
test2<K, boost::hash2::murmur3_32>( N, v );
test2<K, boost::hash2::murmur3_128>( N, v );
test2<K, boost::hash2::xxhash_32>( N, v );
test2<K, boost::hash2::xxhash_64>( N, v );
test2<K, boost::hash2::spooky2_128>( N, v );
test2<K, boost::hash2::siphash_32>( N, v );
test2<K, boost::hash2::siphash_64>( N, v );
test2<K, boost::hash2::md5_128>( N, v );
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions test/Jamfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ run fnv1a.cpp ;
run siphash32.cpp ;
run siphash64.cpp ;
run xxhash.cpp ;
run spooky2.cpp ;
run murmur3_32.cpp ;
run murmur3_128.cpp ;

# cryptographic

Expand All @@ -57,6 +54,12 @@ run hmac_md5.cpp ;
run sha1.cpp ;
run hmac_sha1.cpp ;

# legacy

run legacy/spooky2.cpp ;
run legacy/murmur3_32.cpp ;
run legacy/murmur3_128.cpp ;

# general requirements

run concept.cpp ;
Expand Down
Loading

0 comments on commit 3501a6b

Please sign in to comment.