runtime: Smhasher tests of our map hash function.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/13436045
This commit is contained in:
Keith Randall 2013-09-06 16:23:46 -07:00
parent da7a51d16b
commit 78338d8c66
3 changed files with 550 additions and 0 deletions

View file

@ -513,3 +513,29 @@ runtime·equal(Type *t, ...)
ret = ROUND(ret, Structrnd);
t->alg->equal((bool*)ret, t->size, x, y);
}
// Testing adapters for hash quality tests (see hash_test.go)
void runtime·haveGoodHash(bool res) {
res = use_aeshash;
FLUSH(&res);
}
void runtime·stringHash(String s, uintptr seed, uintptr res) {
runtime·algarray[ASTRING].hash(&seed, sizeof(String), &s);
res = seed;
FLUSH(&res);
}
void runtime·bytesHash(Slice s, uintptr seed, uintptr res) {
runtime·algarray[AMEM].hash(&seed, s.len, s.array);
res = seed;
FLUSH(&res);
}
void runtime·int32Hash(uint32 i, uintptr seed, uintptr res) {
runtime·algarray[AMEM32].hash(&seed, sizeof(uint32), &i);
res = seed;
FLUSH(&res);
}
void runtime·int64Hash(uint64 i, uintptr seed, uintptr res) {
runtime·algarray[AMEM64].hash(&seed, sizeof(uint64), &i);
res = seed;
FLUSH(&res);
}