MCPcopy Index your code
hub / github.com/GoEdgeLab/EdgeNode / BenchmarkStat

Function BenchmarkStat

internal/utils/cachehits/stat_test.go:87–107  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

85}
86
87func BenchmarkStat(b *testing.B) {
88 runtime.GOMAXPROCS(4)
89
90 var stat = cachehits.NewStat(5)
91 for i := 0; i < 1_000_000; i++ {
92 stat.IncreaseCached("a" + types.String(i))
93 }
94
95 b.ResetTimer()
96
97 b.RunParallel(func(pb *testing.PB) {
98 for pb.Next() {
99 var key = strconv.Itoa(rands.Int(0, 100_000))
100 stat.IncreaseCached(key)
101 if rands.Int(0, 3) == 0 {
102 stat.IncreaseHit(key)
103 }
104 _ = stat.IsGood(key)
105 }
106 })
107}

Callers

nothing calls this directly

Calls 6

NewStatFunction · 0.92
IncreaseCachedMethod · 0.80
NextMethod · 0.80
IsGoodMethod · 0.80
IncreaseHitMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected