(b *testing.B, shards int, lifeWindow time.Duration, requestsInLifeWindow int)
| 143 | } |
| 144 | |
| 145 | func appendToCache(b *testing.B, shards int, lifeWindow time.Duration, requestsInLifeWindow int) { |
| 146 | cache, _ := New(context.Background(), Config{ |
| 147 | Shards: shards, |
| 148 | LifeWindow: lifeWindow, |
| 149 | MaxEntriesInWindow: max(requestsInLifeWindow, 100), |
| 150 | MaxEntrySize: 2000, |
| 151 | }) |
| 152 | rand.Seed(time.Now().Unix()) |
| 153 | |
| 154 | b.RunParallel(func(pb *testing.PB) { |
| 155 | id := rand.Int() |
| 156 | counter := 0 |
| 157 | |
| 158 | b.ReportAllocs() |
| 159 | for pb.Next() { |
| 160 | key := fmt.Sprintf("key-%d-%d", id, counter) |
| 161 | for j := 0; j < 7; j++ { |
| 162 | cache.Append(key, message) |
| 163 | } |
| 164 | counter = counter + 1 |
| 165 | } |
| 166 | }) |
| 167 | } |
| 168 | |
| 169 | func readFromCache(b *testing.B, shards int, info bool) { |
| 170 | cache, _ := New(context.Background(), Config{ |
no test coverage detected
searching dependent graphs…