Don't overparallelize the concurrent test.
This commit is contained in:
parent
3c46230312
commit
fbcdb10061
|
@ -646,10 +646,20 @@ func BenchmarkCacheGetConcurrent(b *testing.B) {
|
||||||
tc := New(0, 0)
|
tc := New(0, 0)
|
||||||
tc.Set("foo", "bar", 0)
|
tc.Set("foo", "bar", 0)
|
||||||
wg := new(sync.WaitGroup)
|
wg := new(sync.WaitGroup)
|
||||||
wg.Add(b.N)
|
children := b.N
|
||||||
for i := 0; i < b.N; i++ {
|
iterations := 1
|
||||||
|
|
||||||
|
if children > 10000 {
|
||||||
|
children = 10000
|
||||||
|
iterations = b.N / children
|
||||||
|
}
|
||||||
|
|
||||||
|
wg.Add(children)
|
||||||
|
for i := 0; i < children; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
tc.Get("foo")
|
for j := 0; j < iterations; j++ {
|
||||||
|
tc.Get("foo")
|
||||||
|
}
|
||||||
wg.Done()
|
wg.Done()
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue