aboutsummaryrefslogtreecommitdiff
path: root/src/hash
diff options
context:
space:
mode:
authorqiulaidongfeng <2645477756@qq.com>2024-02-16 01:51:54 +0000
committerGopher Robot <gobot@golang.org>2024-02-20 14:56:36 +0000
commit0a04641871d8a035da0f088899f414d21067f342 (patch)
tree432e70630a152e60e3003bd06459fa418ce33c8c /src/hash
parent098a87fb1930b9ef99d394fe1bca75f1bd74ce8d (diff)
downloadgo-0a04641871d8a035da0f088899f414d21067f342.tar.gz
go-0a04641871d8a035da0f088899f414d21067f342.zip
hash/maphash: parallel run test
This reduces the go test hash/maphash time by more than half. Change-Id: If184ca99544809c86b4c1baeb45d3afede91b41a GitHub-Last-Rev: 440c35f8b544a16cc733e3291f963f738dd59a47 GitHub-Pull-Request: golang/go#65739 Reviewed-on: https://go-review.googlesource.com/c/go/+/564576 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'src/hash')
-rw-r--r--src/hash/maphash/smhasher_test.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hash/maphash/smhasher_test.go b/src/hash/maphash/smhasher_test.go
index 085036bd7b..c183243809 100644
--- a/src/hash/maphash/smhasher_test.go
+++ b/src/hash/maphash/smhasher_test.go
@@ -29,6 +29,7 @@ var fixedSeed = MakeSeed()
// hash should not depend on values outside key.
// hash should not depend on alignment.
func TestSmhasherSanity(t *testing.T) {
+ t.Parallel()
r := rand.New(rand.NewSource(1234))
const REP = 10
const KEYMAX = 128
@@ -107,6 +108,7 @@ func (s *hashSet) check(t *testing.T) {
// a string plus adding zeros must make distinct hashes
func TestSmhasherAppendedZeros(t *testing.T) {
+ t.Parallel()
s := "hello" + strings.Repeat("\x00", 256)
h := newHashSet()
for i := 0; i <= len(s); i++ {
@@ -117,6 +119,7 @@ func TestSmhasherAppendedZeros(t *testing.T) {
// All 0-3 byte strings have distinct hashes.
func TestSmhasherSmallKeys(t *testing.T) {
+ t.Parallel()
h := newHashSet()
var b [3]byte
for i := 0; i < 256; i++ {
@@ -138,6 +141,7 @@ func TestSmhasherSmallKeys(t *testing.T) {
// Different length strings of all zeros have distinct hashes.
func TestSmhasherZeros(t *testing.T) {
+ t.Parallel()
N := 256 * 1024
if testing.Short() {
N = 1024
@@ -158,6 +162,7 @@ func TestSmhasherTwoNonzero(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
h := newHashSet()
for n := 2; n <= 16; n++ {
twoNonZero(h, n)
@@ -200,6 +205,7 @@ func TestSmhasherCyclic(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
r := rand.New(rand.NewSource(1234))
const REPEAT = 8
const N = 1000000
@@ -229,6 +235,7 @@ func TestSmhasherSparse(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
sparse(t, 32, 6)
sparse(t, 40, 6)
sparse(t, 48, 5)
@@ -267,6 +274,7 @@ func TestSmhasherPermutation(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
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)
@@ -407,6 +415,7 @@ func windowed(t *testing.T, k key) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
const BITS = 16
for r := 0; r < k.bits(); r++ {
@@ -429,6 +438,7 @@ func TestSmhasherText(t *testing.T) {
if testing.Short() {
t.Skip("Skipping in short mode")
}
+ t.Parallel()
text(t, "Foo", "Bar")
text(t, "FooBar", "")
text(t, "", "FooBar")
@@ -463,6 +473,7 @@ func TestSmhasherSeed(t *testing.T) {
if unsafe.Sizeof(uintptr(0)) == 4 {
t.Skip("32-bit platforms don't have ideal seed-input distributions (see issue 33988)")
}
+ t.Parallel()
h := newHashSet()
const N = 100000
s := "hello"