aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/hash_test.go
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2014-12-10 17:02:58 -0800
committerKeith Randall <khr@golang.org>2014-12-22 22:41:01 +0000
commitcda0ea1c0e06d1309f66423a8fd72e272d089b6c (patch)
tree5720fe98083a2945524142f33a9c6720eea19221 /src/runtime/hash_test.go
parentfbc56cf05015899aba236d5a68096a770de3ad0a (diff)
downloadgo-cda0ea1c0e06d1309f66423a8fd72e272d089b6c.tar.gz
go-cda0ea1c0e06d1309f66423a8fd72e272d089b6c.zip
runtime: a better fallback hash
For arm and powerpc, as well as x86 without aes instructions. Contains a mixture of ideas from cityhash and xxhash. Compared to our old fallback on ARM, it's ~no slower on small objects and up to ~50% faster on large objects. More importantly, it is a much better hash function and thus has less chance of bad behavior. Fixes #8737 benchmark old ns/op new ns/op delta BenchmarkHash5 173 181 +4.62% BenchmarkHash16 252 212 -15.87% BenchmarkHash64 575 419 -27.13% BenchmarkHash1024 7173 3995 -44.31% BenchmarkHash65536 516940 313173 -39.42% BenchmarkHashStringSpeed 300 279 -7.00% BenchmarkHashBytesSpeed 478 424 -11.30% BenchmarkHashInt32Speed 217 207 -4.61% BenchmarkHashInt64Speed 262 231 -11.83% BenchmarkHashStringArraySpeed 609 631 +3.61% Change-Id: I0a9335028f32b10ad484966e3019987973afd3eb Reviewed-on: https://go-review.googlesource.com/1360 Reviewed-by: Russ Cox <rsc@golang.org>
Diffstat (limited to 'src/runtime/hash_test.go')
-rw-r--r--src/runtime/hash_test.go9
1 files changed, 0 insertions, 9 deletions
diff --git a/src/runtime/hash_test.go b/src/runtime/hash_test.go
index 41fff98eb0..6b229bdb88 100644
--- a/src/runtime/hash_test.go
+++ b/src/runtime/hash_test.go
@@ -171,9 +171,6 @@ func TestSmhasherCyclic(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
- if !HaveGoodHash() {
- t.Skip("fallback hash not good enough for this test")
- }
r := rand.New(rand.NewSource(1234))
const REPEAT = 8
const N = 1000000
@@ -235,9 +232,6 @@ func TestSmhasherPermutation(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
- if !HaveGoodHash() {
- t.Skip("fallback hash not good enough for this test")
- }
permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
permutation(t, []uint32{0, 1}, 20)
@@ -404,9 +398,6 @@ func (k *IfaceKey) name() string {
// Flipping a single bit of a key should flip each output bit with 50% probability.
func TestSmhasherAvalanche(t *testing.T) {
- if !HaveGoodHash() {
- t.Skip("fallback hash not good enough for this test")
- }
if testing.Short() {
t.Skip("Skipping in short mode")
}