MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkMemoryList

Function BenchmarkMemoryList

internal/caches/list_memory_test.go:302–327  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

300}
301
302func BenchmarkMemoryList(b *testing.B) {
303 var list = caches.NewMemoryList()
304 err := list.Init()
305 if err != nil {
306 b.Fatal(err)
307 }
308 for i := 0; i < 1_000_000; i++ {
309 _ = list.Add(stringutil.Md5(types.String(i)), &caches.Item{
310 Key: "a1",
311 ExpiresAt: time.Now().Unix() + 3600,
312 HeaderSize: 1024,
313 })
314 }
315
316 b.ResetTimer()
317
318 b.RunParallel(func(pb *testing.PB) {
319 for pb.Next() {
320 _, _, _ = list.Exist(types.String("a" + types.String(rands.Int(1, 10000))))
321 _ = list.Add("a"+types.String(rands.Int(1, 100000)), &caches.Item{})
322 _, _ = list.Purge(1000, func(hash string) error {
323 return nil
324 })
325 }
326 })
327}

Callers

nothing calls this directly

Calls 8

NewMemoryListFunction · 0.92
UnixMethod · 0.80
NextMethod · 0.80
InitMethod · 0.65
AddMethod · 0.65
ExistMethod · 0.65
PurgeMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected