diff --git a/internal/clock/clock.go b/internal/clock/clock.go index 4a0367a62..8ec9b8fbf 100644 --- a/internal/clock/clock.go +++ b/internal/clock/clock.go @@ -63,6 +63,7 @@ func calcCountFromTPS(tps int64, now int64) int { diff := now - lastSystemTime if diff < 0 { // It is theoretically possible to change the OS clock, so now can be older than lastSystemTime. + lastSystemTime = now return 0 } @@ -101,6 +102,13 @@ func updateFPSAndTPS(now int64, count int) { } fpsCount++ tpsCount += count + if now < lastUpdated { + // It is theoretically possible to change the OS clock, so now can be older than lastSystemTime. + lastUpdated = now + fpsCount = 0 + tpsCount = 0 + return + } if time.Second > time.Duration(now-lastUpdated) { return }