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

Function BenchmarkCacheGet

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

Source from the content-addressed store, hash-verified

991}
992
993func BenchmarkCacheGet(b *testing.B) {
994 b.ReportAllocs()
995 b.StopTimer()
996 cache := NewCache(256 * 1024 * 1024)
997 var key [8]byte
998 buf := make([]byte, 64)
999 for i := 0; i < b.N; i++ {
1000 binary.LittleEndian.PutUint64(key[:], uint64(i))
1001 cache.Set(key[:], buf, 0)
1002 }
1003 b.StartTimer()
1004 for i := 0; i < b.N; i++ {
1005 binary.LittleEndian.PutUint64(key[:], uint64(i))
1006 cache.Get(key[:])
1007 }
1008}
1009
1010func BenchmarkCacheGetFn(b *testing.B) {
1011 b.ReportAllocs()

Callers

nothing calls this directly

Calls 3

SetMethod · 0.95
GetMethod · 0.95
NewCacheFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…