优化统计性能

This commit is contained in:
GoEdgeLab
2023-04-07 11:23:37 +08:00
parent 93c5d03a49
commit 6c6317af56
4 changed files with 49 additions and 15 deletions

View File

@@ -34,6 +34,17 @@ func TestBandwidthStatManager_Loop(t *testing.T) {
}
}
func BenchmarkBandwidthStatManager_Add(b *testing.B) {
var manager = stats.NewBandwidthStatManager()
b.RunParallel(func(pb *testing.PB) {
var i int
for pb.Next() {
i++
manager.AddBandwidth(1, int64(i%100), 10, 10)
}
})
}
func BenchmarkBandwidthStatManager_Slice(b *testing.B) {
runtime.GOMAXPROCS(1)