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

Function BenchmarkCounter_IncreaseKey

internal/utils/counters/counter_test.go:130–153  ·  view source on GitHub ↗
(b *testing.B)

Source from the content-addressed store, hash-verified

128}
129
130func BenchmarkCounter_IncreaseKey(b *testing.B) {
131 runtime.GOMAXPROCS(4)
132
133 var counter = counters.NewCounter[uint32]()
134
135 go func() {
136 var ticker = time.NewTicker(100 * time.Millisecond)
137 for range ticker.C {
138 counter.GC()
139 }
140 }()
141
142 b.ResetTimer()
143 b.ReportAllocs()
144
145 var i uint64
146 b.RunParallel(func(pb *testing.PB) {
147 for pb.Next() {
148 counter.IncreaseKey(types.String(atomic.AddUint64(&i, 1)%1_000_000), 20)
149 }
150 })
151
152 //b.Log(counter.TotalItems())
153}
154
155func BenchmarkCounter_IncreaseKey2(b *testing.B) {
156 runtime.GOMAXPROCS(4)

Callers

nothing calls this directly

Calls 4

NextMethod · 0.80
IncreaseKeyMethod · 0.80
GCMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected