(b *testing.B, exp time.Duration)
| 60 | } |
| 61 | |
| 62 | func benchmarkShardedCacheGetManyConcurrent(b *testing.B, exp time.Duration) { |
| 63 | b.StopTimer() |
| 64 | n := 10000 |
| 65 | tsc := unexportedNewSharded(exp, 0, 20) |
| 66 | keys := make([]string, n) |
| 67 | for i := 0; i < n; i++ { |
| 68 | k := "foo" + strconv.Itoa(n) |
| 69 | keys[i] = k |
| 70 | tsc.Set(k, "bar", DefaultExpiration) |
| 71 | } |
| 72 | each := b.N / n |
| 73 | wg := new(sync.WaitGroup) |
| 74 | wg.Add(n) |
| 75 | for _, v := range keys { |
| 76 | go func() { |
| 77 | for j := 0; j < each; j++ { |
| 78 | tsc.Get(v) |
| 79 | } |
| 80 | wg.Done() |
| 81 | }() |
| 82 | } |
| 83 | b.StartTimer() |
| 84 | wg.Wait() |
| 85 | } |
no test coverage detected
searching dependent graphs…