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>
This commit is contained in:
parent
57af736625
commit
f52d1811a6
1 changed files with 2 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue