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

Function BenchmarkValuesMap

internal/caches/storage_memory_test.go:359–384  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

357}
358
359func BenchmarkValuesMap(b *testing.B) {
360 var m = map[uint64]*MemoryItem{}
361 var count = 1_000_000
362 for i := 0; i < count; i++ {
363 m[uint64(i)] = &MemoryItem{
364 ExpiresAt: time.Now().Unix(),
365 }
366 }
367 b.Log(len(m))
368
369 var locker = sync.Mutex{}
370 b.ResetTimer()
371
372 b.RunParallel(func(pb *testing.PB) {
373 for pb.Next() {
374 locker.Lock()
375 _, ok := m[uint64(rands.Int(0, 1_000_000))]
376 _ = ok
377 locker.Unlock()
378
379 locker.Lock()
380 delete(m, uint64(rands.Int(2, 1000000)))
381 locker.Unlock()
382 }
383 })
384}
385
386func BenchmarkNewMemoryStorage(b *testing.B) {
387 var storage = NewMemoryStorage(&serverconfigs.HTTPCachePolicy{}, nil)

Callers

nothing calls this directly

Calls 5

UnixMethod · 0.80
LogMethod · 0.80
NextMethod · 0.80
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected