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

Function BenchmarkParallelCacheGetWithBuf

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

Source from the content-addressed store, hash-verified

1068}
1069
1070func BenchmarkParallelCacheGetWithBuf(b *testing.B) {
1071 b.ReportAllocs()
1072 b.StopTimer()
1073 cache := NewCache(256 * 1024 * 1024)
1074 var key [8]byte
1075 buf := make([]byte, 64)
1076 for i := 0; i < b.N; i++ {
1077 binary.LittleEndian.PutUint64(key[:], uint64(i))
1078 cache.Set(key[:], buf, 0)
1079 }
1080 b.StartTimer()
1081
1082 b.RunParallel(func(pb *testing.PB) {
1083 counter := 0
1084 b.ReportAllocs()
1085 for pb.Next() {
1086 binary.LittleEndian.PutUint64(key[:], uint64(counter))
1087 cache.GetWithBuf(key[:], buf)
1088 counter = counter + 1
1089 }
1090 })
1091}
1092
1093func BenchmarkCacheGetWithExpiration(b *testing.B) {
1094 b.StopTimer()

Callers

nothing calls this directly

Calls 4

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