(b *testing.B, exp time.Duration)
| 1547 | } |
| 1548 | |
| 1549 | func benchmarkCacheGetManyConcurrent(b *testing.B, exp time.Duration) { |
| 1550 | // This is the same as BenchmarkCacheGetConcurrent, but its result |
| 1551 | // can be compared against BenchmarkShardedCacheGetManyConcurrent |
| 1552 | // in sharded_test.go. |
| 1553 | b.StopTimer() |
| 1554 | n := 10000 |
| 1555 | tc := New(exp, 0) |
| 1556 | keys := make([]string, n) |
| 1557 | for i := 0; i < n; i++ { |
| 1558 | k := "foo" + strconv.Itoa(n) |
| 1559 | keys[i] = k |
| 1560 | tc.Set(k, "bar", DefaultExpiration) |
| 1561 | } |
| 1562 | each := b.N / n |
| 1563 | wg := new(sync.WaitGroup) |
| 1564 | wg.Add(n) |
| 1565 | for _, v := range keys { |
| 1566 | go func() { |
| 1567 | for j := 0; j < each; j++ { |
| 1568 | tc.Get(v) |
| 1569 | } |
| 1570 | wg.Done() |
| 1571 | }() |
| 1572 | } |
| 1573 | b.StartTimer() |
| 1574 | wg.Wait() |
| 1575 | } |
| 1576 | |
| 1577 | func BenchmarkCacheSetExpiring(b *testing.B) { |
| 1578 | benchmarkCacheSet(b, 5*time.Minute) |
no test coverage detected
searching dependent graphs…