-
Notifications
You must be signed in to change notification settings - Fork 1
/
x_performance.go
47 lines (38 loc) · 1.13 KB
/
x_performance.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package gopl
//
// Author: 陈永佳 [email protected], [email protected]
//
// 统计消息处理性能的最大消息数量
const MaxSamplesCountPerformanceAvg = 1024
// 消息处理性能
type DataFrameSamples struct {
InboundSamples *IntSamples
OutboundSamples *IntSamples
FilteredSamples *IntSamples
}
var gPerformanceSamples = DataFrameSamples{
InboundSamples: NewIntSamples(MaxSamplesCountPerformanceAvg),
OutboundSamples: NewIntSamples(MaxSamplesCountPerformanceAvg),
FilteredSamples: NewIntSamples(MaxSamplesCountPerformanceAvg),
}
func sampleInbound(du int64) {
gPerformanceSamples.InboundSamples.AddSample(du)
}
func sampleFilter(du int64) {
gPerformanceSamples.FilteredSamples.AddSample(du)
}
func sampleOutbounds(du int64) {
gPerformanceSamples.OutboundSamples.AddSample(du)
}
type AvgSamples struct {
InboundsAvg int64
OutboundsAvg int64
FilteredAvg int64
}
func TakeDataFramesAvgSamples() AvgSamples {
return AvgSamples{
InboundsAvg: gPerformanceSamples.InboundSamples.Avg(),
OutboundsAvg: gPerformanceSamples.OutboundSamples.Avg(),
FilteredAvg: gPerformanceSamples.FilteredSamples.Avg(),
}
}