(b *testing.B, exp time.Duration)
| 1563 | } |
| 1564 | |
| 1565 | func benchmarkCacheGetManyConcurrent(b *testing.B, exp time.Duration) { |
| 1566 | // This is the same as BenchmarkCacheGetConcurrent, but its result |
| 1567 | // can be compared against BenchmarkShardedCacheGetManyConcurrent |
| 1568 | // in sharded_test.go. |
| 1569 | b.StopTimer() |
| 1570 | n := 10000 |
| 1571 | tc := New(exp, 0) |
| 1572 | keys := make([]string, n) |
| 1573 | for i := 0; i < n; i++ { |
| 1574 | k := "foo" + strconv.Itoa(n) |
| 1575 | keys[i] = k |
| 1576 | tc.Set(k, "bar", DefaultExpiration) |
| 1577 | } |
| 1578 | each := b.N / n |
| 1579 | wg := new(sync.WaitGroup) |
| 1580 | wg.Add(n) |
| 1581 | for _, v := range keys { |
| 1582 | go func() { |
| 1583 | for j := 0; j < each; j++ { |
| 1584 | tc.Get(v) |
| 1585 | } |
| 1586 | wg.Done() |
| 1587 | }() |
| 1588 | } |
| 1589 | b.StartTimer() |
| 1590 | wg.Wait() |
| 1591 | } |
| 1592 | |
| 1593 | func BenchmarkCacheSetExpiring(b *testing.B) { |
| 1594 | benchmarkCacheSet(b, 5*time.Minute) |
no test coverage detected