MCPcopy Create free account
hub / github.com/go-dev-frame/sponge / BenchmarkGetFromMemory

Function BenchmarkGetFromMemory

pkg/cache/memory_test.go:140–157  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

138}
139
140func BenchmarkGetFromMemory(b *testing.B) {
141 c := newMemoryCache()
142 defer c.Close()
143 testData := c.TestDataSlice[0].(*memoryUser)
144 iCache := c.ICache.(Cache)
145
146 key := utils.Uint64ToStr(testData.ID)
147 err := iCache.Set(c.Ctx, key, c.TestDataMap[key], time.Minute)
148 if err != nil {
149 b.Error(err)
150 return
151 }
152
153 for i := 0; i < b.N; i++ {
154 val := &memoryUser{}
155 _ = iCache.Get(c.Ctx, key, val)
156 }
157}

Callers

nothing calls this directly

Calls 6

Uint64ToStrFunction · 0.92
newMemoryCacheFunction · 0.85
CloseMethod · 0.65
SetMethod · 0.65
ErrorMethod · 0.65
GetMethod · 0.65

Tested by

no test coverage detected