aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Amsterdam <jba@google.com>2017-05-17 16:25:26 -0400
committerBrad Fitzpatrick <bradfitz@golang.org>2017-05-17 21:12:32 +0000
commitf52d1811a62927559de87708c8913c1650ce4f26 (patch)
tree8004aa51e26203cfdc5d2847caf4b0c4c66c3431
parent57af736625aaa69dfa099432bb67e0808eef3bcc (diff)
downloadgolang-x-sync-f52d1811a62927559de87708c8913c1650ce4f26.tar.gz
semaphore: make test time independent of GOMAXPROCS
TestWeighted's runtime was roughly proportional to the number of CPUs, so it ran a long time on PPCs (160 CPUs). Make the number of loops in the test an inverse function of the number of CPUs, to keep the test short. Change-Id: Id853dbb5e5e2f9fb95966d19ef0c511e3f8080e0 Reviewed-on: https://go-review.googlesource.com/43632 Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--semaphore/semaphore_test.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/semaphore/semaphore_test.go b/semaphore/semaphore_test.go
index 867f71a..3f3bc9f 100644
--- a/semaphore/semaphore_test.go
+++ b/semaphore/semaphore_test.go
@@ -29,6 +29,7 @@ func TestWeighted(t *testing.T) {
t.Parallel()
n := runtime.GOMAXPROCS(0)
+ loops := 10000 / n
sem := NewWeighted(int64(n))
var wg sync.WaitGroup
wg.Add(n)
@@ -36,7 +37,7 @@ func TestWeighted(t *testing.T) {
i := i
go func() {
defer wg.Done()
- HammerWeighted(sem, int64(i), 1000)
+ HammerWeighted(sem, int64(i), loops)
}()
}
wg.Wait()