MCPcopy Create free account
hub / github.com/allegro/bigcache / appendToCache

Function appendToCache

bigcache_bench_test.go:145–167  ·  view source on GitHub ↗
(b *testing.B, shards int, lifeWindow time.Duration, requestsInLifeWindow int)

Source from the content-addressed store, hash-verified

143}
144
145func 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
169func readFromCache(b *testing.B, shards int, info bool) {
170 cache, _ := New(context.Background(), Config{

Callers 1

BenchmarkAppendToCacheFunction · 0.85

Calls 3

NewFunction · 0.85
maxFunction · 0.85
AppendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…