(b *testing.B, metrics bool)
| 92 | } |
| 93 | |
| 94 | func benchRistrettoGetHitParallel(b *testing.B, metrics bool) { |
| 95 | c := newBenchCache(b, metrics) |
| 96 | defer c.Close() |
| 97 | |
| 98 | const entries = 1 << 16 |
| 99 | val := make([]byte, 256) |
| 100 | for i := range entries { |
| 101 | c.Set(uint64(i), val, int64(len(val))) |
| 102 | } |
| 103 | c.Wait() |
| 104 | |
| 105 | b.ReportAllocs() |
| 106 | b.ResetTimer() |
| 107 | |
| 108 | b.RunParallel(func(pb *testing.PB) { |
| 109 | // Give each worker a distinct offset so they don't all hammer the same key. |
| 110 | // strconv is a cheap way to get some per-goroutine entropy here. |
| 111 | var off uint64 |
| 112 | if s := strconv.Itoa(int(b.N)); len(s) > 0 { |
| 113 | off = uint64(s[0]) |
| 114 | } |
| 115 | var i uint64 |
| 116 | for pb.Next() { |
| 117 | _, _ = c.Get((i + off) & (entries - 1)) |
| 118 | i++ |
| 119 | } |
| 120 | }) |
| 121 | } |
no test coverage detected
searching dependent graphs…