From fbcdb100616dde39cd62ad7d9e1213170f6d6194 Mon Sep 17 00:00:00 2001 From: Dustin Sallings Date: Thu, 21 Jun 2012 17:36:24 -0700 Subject: [PATCH] Don't overparallelize the concurrent test. --- cache_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/cache_test.go b/cache_test.go index 4330d56..cd1d1e5 100644 --- a/cache_test.go +++ b/cache_test.go @@ -646,10 +646,20 @@ func BenchmarkCacheGetConcurrent(b *testing.B) { tc := New(0, 0) tc.Set("foo", "bar", 0) wg := new(sync.WaitGroup) - wg.Add(b.N) - for i := 0; i < b.N; i++ { + children := b.N + iterations := 1 + + if children > 10000 { + children = 10000 + iterations = b.N / children + } + + wg.Add(children) + for i := 0; i < children; i++ { go func() { - tc.Get("foo") + for j := 0; j < iterations; j++ { + tc.Get("foo") + } wg.Done() }() }