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

Function BenchmarkParallelCacheGet

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

Source from the content-addressed store, hash-verified

1029}
1030
1031func BenchmarkParallelCacheGet(b *testing.B) {
1032 b.ReportAllocs()
1033 b.StopTimer()
1034 cache := NewCache(256 * 1024 * 1024)
1035 buf := make([]byte, 64)
1036 var key [8]byte
1037 for i := 0; i < b.N; i++ {
1038 binary.LittleEndian.PutUint64(key[:], uint64(i))
1039 cache.Set(key[:], buf, 0)
1040 }
1041 b.StartTimer()
1042 b.RunParallel(func(pb *testing.PB) {
1043 counter := 0
1044 b.ReportAllocs()
1045 for pb.Next() {
1046 binary.LittleEndian.PutUint64(key[:], uint64(counter))
1047 cache.Get(key[:])
1048 counter = counter + 1
1049 }
1050 })
1051}
1052
1053func BenchmarkCacheGetWithBuf(b *testing.B) {
1054 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…