Files
open-im-server/pkg/statistics/statistics.go
T

32 lines
650 B
Go
Raw Normal View History

2022-02-25 19:29:39 +08:00
package statistics
2022-02-25 19:39:42 +08:00
import (
"time"
)
2022-02-25 19:29:39 +08:00
type Statistics struct {
2022-02-25 19:39:42 +08:00
Count *uint64
ModuleName string
PrintArgs string
SleepTime int
2022-02-25 19:29:39 +08:00
}
func (s *Statistics) output() {
2022-02-25 19:39:42 +08:00
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
defer t.Stop()
2022-03-04 16:11:04 +08:00
//var sum uint64
2022-02-25 19:29:39 +08:00
for {
2022-03-04 16:11:04 +08:00
//sum = *s.Count
2022-02-25 19:39:42 +08:00
select {
case <-t.C:
}
2022-03-04 16:11:04 +08:00
//log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
2022-02-25 19:29:39 +08:00
}
}
2022-02-25 19:39:42 +08:00
func NewStatistics(count *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{Count: count, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
2022-02-25 19:29:39 +08:00
go p.output()
2022-02-25 19:39:42 +08:00
return p
2022-02-25 19:29:39 +08:00
}