Skip to content

Commit f52d181

Browse files
jbabradfitz
authored andcommitted
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>
1 parent 57af736 commit f52d181

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

semaphore/semaphore_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@ func TestWeighted(t *testing.T) {
2929
t.Parallel()
3030

3131
n := runtime.GOMAXPROCS(0)
32+
loops := 10000 / n
3233
sem := NewWeighted(int64(n))
3334
var wg sync.WaitGroup
3435
wg.Add(n)
3536
for i := 0; i < n; i++ {
3637
i := i
3738
go func() {
3839
defer wg.Done()
39-
HammerWeighted(sem, int64(i), 1000)
40+
HammerWeighted(sem, int64(i), loops)
4041
}()
4142
}
4243
wg.Wait()

0 commit comments

Comments
 (0)