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

Function BenchmarkParallelCacheGetBatched

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

Source from the content-addressed store, hash-verified

1111)
1112
1113func BenchmarkParallelCacheGetBatched(b *testing.B) {
1114 b.ReportAllocs()
1115 b.StopTimer()
1116 cache := NewCache(256 * 1024 * 1024)
1117 buf := make([]byte, 64)
1118 var key [8]byte
1119 for i := 0; i < benchDataSize; i++ {
1120 binary.LittleEndian.PutUint64(key[:], uint64(i))
1121 cache.Set(key[:], buf, 0)
1122 }
1123 b.StartTimer()
1124 b.RunParallel(func(pb *testing.PB) {
1125 keys := make([][]byte, benchBatchSize)
1126 for i := range keys {
1127 keys[i] = make([]byte, 8)
1128 }
1129 i := 0
1130 for pb.Next() {
1131 for j := 0; j < benchBatchSize; j++ {
1132 binary.LittleEndian.PutUint64(key[:], uint64((i+j)%benchDataSize))
1133 cache.Get(key[:])
1134 }
1135 i++
1136 }
1137 })
1138}
1139
1140func BenchmarkParallelCacheMultiGetBatched(b *testing.B) {
1141 b.ReportAllocs()

Callers

nothing calls this directly

Calls 4

SetMethod · 0.95
GetMethod · 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…