-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathperformance.go
More file actions
41 lines (36 loc) · 935 Bytes
/
performance.go
File metadata and controls
41 lines (36 loc) · 935 Bytes
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
package iland
type PerformanceCounter struct {
Name string `json:"name"`
Type string `json:"type"`
Group string `json:"group"`
}
type Performance struct {
ID string `json:"uuid"`
Name string `json:"name"`
Type string `json:"type"`
Group string `json:"group"`
Summary string `json:"summary"`
Interval int `json:"interval"`
Unit string `json:"unit"`
Samples []PerformanceSample `json:"samples"`
}
type PerformanceSample struct {
Value int `json:"value"`
Timestamp int `json:"time"`
}
func (p *Performance) GetMaxValue() int {
max := 0
for _, sample := range p.Samples {
if sample.Value > max {
max = sample.Value
}
}
return max
}
func (p *Performance) GetAvgValue() int {
total := 0
for _, sample := range p.Samples {
total += sample.Value
}
return int(total / len(p.Samples))
}