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

Function BenchmarkIterateOverCache

bigcache_bench_test.go:79–110  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

77 }
78}
79func BenchmarkIterateOverCache(b *testing.B) {
80
81 m := blob('a', 1)
82
83 for _, shards := range []int{512, 1024, 8192} {
84 b.Run(fmt.Sprintf("%d-shards", shards), func(b *testing.B) {
85 cache, _ := New(context.Background(), Config{
86 Shards: shards,
87 LifeWindow: 1000 * time.Second,
88 MaxEntriesInWindow: max(b.N, 100),
89 MaxEntrySize: 500,
90 })
91
92 for i := 0; i < b.N; i++ {
93 cache.Set(fmt.Sprintf("key-%d", i), m)
94 }
95
96 b.ResetTimer()
97 it := cache.Iterator()
98
99 b.RunParallel(func(pb *testing.PB) {
100 b.ReportAllocs()
101
102 for pb.Next() {
103 if it.SetNext() {
104 it.Value()
105 }
106 }
107 })
108 })
109 }
110}
111
112func BenchmarkWriteToCacheWith1024ShardsAndSmallShardInitSize(b *testing.B) {
113 writeToCache(b, 1024, 100*time.Second, 100)

Callers

nothing calls this directly

Calls 7

NewFunction · 0.85
maxFunction · 0.85
SetMethod · 0.80
IteratorMethod · 0.80
SetNextMethod · 0.80
blobFunction · 0.70
ValueMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…