expvarmon/stat.go

27 lines
450 B
Go
Raw Normal View History

package main
// Stat holds basic statistics data for
// integer data used for sparklines.
type Stat struct {
2016-11-14 04:29:14 +08:00
max int
maxStr string
}
// NewStat inits new Stat object.
func NewStat() *Stat {
2016-11-14 04:29:14 +08:00
return &Stat{}
}
// Update updates stats on each push.
func (s *Stat) Update(v IntVar) {
2016-11-14 04:29:14 +08:00
if v.Value() > s.max {
s.max = v.Value()
s.maxStr = v.String()
}
}
// Max returns maximum recorded value.
2016-11-14 04:29:14 +08:00
func (s *Stat) Max() string {
return s.maxStr
}