mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-13 13:35:59 +08:00
feat: use robot to migrate code
Signed-off-by: kubbot & kubecub <3293172751ysy@gmail.com>
This commit is contained in:
@@ -1,32 +1,41 @@
|
||||
package statistics
|
||||
|
||||
import (
|
||||
"Open_IM/pkg/common/log"
|
||||
"context"
|
||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Statistics struct {
|
||||
Count *uint64
|
||||
AllCount *uint64
|
||||
ModuleName string
|
||||
PrintArgs string
|
||||
SleepTime int
|
||||
SleepTime uint64
|
||||
}
|
||||
|
||||
func (s *Statistics) output() {
|
||||
var intervalCount uint64
|
||||
t := time.NewTicker(time.Duration(s.SleepTime) * time.Second)
|
||||
defer t.Stop()
|
||||
var sum uint64
|
||||
var timeIntervalNum uint64
|
||||
for {
|
||||
sum = *s.Count
|
||||
sum = *s.AllCount
|
||||
select {
|
||||
case <-t.C:
|
||||
}
|
||||
log.NewWarn("", " system stat ", s.ModuleName, s.PrintArgs, *s.Count-sum, "total:", *s.Count)
|
||||
if *s.AllCount-sum <= 0 {
|
||||
intervalCount = 0
|
||||
} else {
|
||||
intervalCount = *s.AllCount - sum
|
||||
}
|
||||
timeIntervalNum++
|
||||
log.ZWarn(context.Background(), " system stat ", nil, "args", s.PrintArgs, "intervalCount", intervalCount, "total:", *s.AllCount, "intervalNum", timeIntervalNum, "avg", (*s.AllCount)/(timeIntervalNum)/s.SleepTime)
|
||||
}
|
||||
}
|
||||
|
||||
func NewStatistics(count *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
|
||||
p := &Statistics{Count: count, ModuleName: moduleName, SleepTime: sleepTime, PrintArgs: printArgs}
|
||||
func NewStatistics(allCount *uint64, moduleName, printArgs string, sleepTime int) *Statistics {
|
||||
p := &Statistics{AllCount: allCount, ModuleName: moduleName, SleepTime: uint64(sleepTime), PrintArgs: printArgs}
|
||||
go p.output()
|
||||
return p
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user