summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortanjent@gmail.com <tanjent@gmail.com@77a7d1d3-4c08-bdc2-d393-d5859734b01a>2010-11-09 20:29:19 +0000
committertanjent@gmail.com <tanjent@gmail.com@77a7d1d3-4c08-bdc2-d393-d5859734b01a>2010-11-09 20:29:19 +0000
commit31a9e8ef5b491fda1cc2f09ebef2353a30b0eb40 (patch)
tree11e21769c3ff3fa666f02747fcbfdc7e57d2fe64
parentad4b363201477cb33966510b850c2193b1f825fe (diff)
downloadsrc-31a9e8ef5b491fda1cc2f09ebef2353a30b0eb40.tar.gz
MurmurHash3_x86_128 was missing a rotate instruction
git-svn-id: http://smhasher.googlecode.com/svn/trunk@58 77a7d1d3-4c08-bdc2-d393-d5859734b01a
-rw-r--r--MurmurHash3.cpp2
-rw-r--r--main.cpp22
2 files changed, 24 insertions, 0 deletions
diff --git a/MurmurHash3.cpp b/MurmurHash3.cpp
index 2942f10..c66bd87 100644
--- a/MurmurHash3.cpp
+++ b/MurmurHash3.cpp
@@ -196,6 +196,8 @@ __forceinline void bmix32 ( uint32_t & h1, uint32_t & h2, uint32_t & h3, uint32_
h1 += h3;
h1 += h4;
+ h1 = _rotl(h1,17);
+
k2 *= c2;
k2 = _rotl(k2,11);
k2 *= c1;
diff --git a/main.cpp b/main.cpp
index 25d3c89..f5fcf04 100644
--- a/main.cpp
+++ b/main.cpp
@@ -42,6 +42,19 @@ bool g_testZeroes = false;
bool g_testSeed = false;
//*/
+
+int64_t g_hashcount = 0;
+int64_t g_bytecount = 0;
+
+void counterhash ( const void * , const int len, const uint32_t , void * out )
+{
+ g_hashcount++;
+ g_bytecount += len;
+
+ *(uint32_t*)out = rand_u32();
+}
+
+
//-----------------------------------------------------------------------------
struct HashInfo
@@ -54,6 +67,7 @@ struct HashInfo
HashInfo g_hashes[] =
{
+ { counterhash, 32, "count", "Counts how many times the hash function is called" },
{ randhash_32, 32, "rand32", "Random number generator, 32-bit" },
{ randhash_64, 64, "rand64", "Random number generator, 64-bit" },
{ randhash_128, 128, "rand128", "Random number generator, 128-bit" },
@@ -387,6 +401,14 @@ int main ( int argc, char ** argv )
//testHash("rand64");
//testHash("rand128");
+ //testHash("donothing");
+
+ //testHash("count");
+
+ //printf("Called the hash function %I64d times, %I64d bytes hashed\n",g_hashcount,g_bytecount);
+
+ //testHash("crc32");
+
//testHash("fnv");
//testHash("superfast");
//testHash("lookup3");