You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/pkg/statistics/statistics.go

33 lines
670 B

3 years ago
package statistics
import (
"Open_IM/pkg/common/log"
"time"
)
3 years ago
type Statistics struct {
Count *uint64
ModuleName string
PrintArgs string
SleepTime int
3 years ago
}
func (s *Statistics) output() {
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
defer t.Stop()
var sum uint64
3 years ago
for {
sum = *s.Count
select {
case <-t.C:
}
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
3 years ago
}
}
func NewStatistics(count *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
p := &Statistics{Count: count, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
3 years ago
go p.output()
return p
3 years ago
}