MCPcopy
hub / github.com/coocood/freecache / BenchmarkParallelCacheMultiGetBatched

Function BenchmarkParallelCacheMultiGetBatched

cache_test.go:1140–1165  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

1138}
1139
1140func BenchmarkParallelCacheMultiGetBatched(b *testing.B) {
1141 b.ReportAllocs()
1142 b.StopTimer()
1143 cache := NewCache(256 * 1024 * 1024)
1144 buf := make([]byte, 64)
1145 var key [8]byte
1146 for i := 0; i < benchDataSize; i++ {
1147 binary.LittleEndian.PutUint64(key[:], uint64(i))
1148 cache.Set(key[:], buf, 0)
1149 }
1150 b.StartTimer()
1151 b.RunParallel(func(pb *testing.PB) {
1152 keys := make([][]byte, benchBatchSize)
1153 for i := range keys {
1154 keys[i] = make([]byte, 8)
1155 }
1156 i := 0
1157 for pb.Next() {
1158 for j := 0; j < benchBatchSize; j++ {
1159 binary.LittleEndian.PutUint64(keys[j], uint64((i+j)%benchDataSize))
1160 }
1161 cache.MultiGet(keys)
1162 i++
1163 }
1164 })
1165}
1166
1167func BenchmarkMapGet(b *testing.B) {
1168 b.StopTimer()

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
MultiGetMethod · 0.95
NewCacheFunction · 0.85
NextMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…