Minor adjustments and new benchmarks
This commit is contained in:
@@ -42,10 +42,28 @@ class MurMurBenchmark {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hash32With39() {
|
||||
val hasher = MurmurHash3()
|
||||
val byteArray = RandomInstance.bytes(39)
|
||||
benchmarkRule.measureRepeated {
|
||||
hasher.hash(byteArray, 293)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hash128() {
|
||||
val hasher = MurmurHash3()
|
||||
val byteArray = RandomInstance.bytes(32)
|
||||
benchmarkRule.measureRepeated {
|
||||
hasher.hash128x64(byteArray, 293L)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun hash128With47Bytes() {
|
||||
val hasher = MurmurHash3()
|
||||
val byteArray = RandomInstance.bytes(47)
|
||||
benchmarkRule.measureRepeated {
|
||||
hasher.hash128x64(byteArray, 293)
|
||||
}
|
||||
|
||||
+4
-3
@@ -95,9 +95,10 @@ class MurmurHash3 {
|
||||
var h2 = seed
|
||||
val roundedEnd = data.size and ROUND_DOWN_128
|
||||
|
||||
var i = 0
|
||||
var k1: Long
|
||||
var k2: Long
|
||||
|
||||
var i = 0
|
||||
while (i < roundedEnd) {
|
||||
k1 =
|
||||
(
|
||||
@@ -124,10 +125,10 @@ class MurmurHash3 {
|
||||
) * C2_128_X64
|
||||
|
||||
h1 = h1 xor k1.rotateLeft(31) * C2_128_X64
|
||||
h1 = (h1.rotateLeft(27) + h2) * 5 + 0x52dce729
|
||||
h1 = (h1.rotateLeft(27) + h2) * 5L + 0x52dce729L
|
||||
|
||||
h2 = h2 xor k2.rotateLeft(33) * C1_128_X64
|
||||
h2 = (h2.rotateLeft(31) + h1) * 5 + 0x38495ab5
|
||||
h2 = (h2.rotateLeft(31) + h1) * 5L + 0x38495ab5L
|
||||
}
|
||||
|
||||
val rem = data.size - roundedEnd
|
||||
|
||||
Reference in New Issue
Block a user