From fdb3a5b121e8064f099ad1d48aa1c0e84103a2df Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Sun, 7 May 2023 18:29:37 +0100 Subject: [PATCH] Fixed incorrect implementation of peak timings --- src/timings/TimingsHandler.php | 2 +- src/timings/TimingsRecord.php | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/timings/TimingsHandler.php b/src/timings/TimingsHandler.php index 9a8234310..45ce022c9 100644 --- a/src/timings/TimingsHandler.php +++ b/src/timings/TimingsHandler.php @@ -32,7 +32,7 @@ use function implode; use function spl_object_id; class TimingsHandler{ - private const FORMAT_VERSION = 1; + private const FORMAT_VERSION = 2; //peak timings fix private static bool $enabled = false; private static int $timingStart = 0; diff --git a/src/timings/TimingsRecord.php b/src/timings/TimingsRecord.php index f09984b5b..2e4928d8a 100644 --- a/src/timings/TimingsRecord.php +++ b/src/timings/TimingsRecord.php @@ -66,9 +66,6 @@ final class TimingsRecord{ if($record->curTickTotal > Server::TARGET_NANOSECONDS_PER_TICK){ $record->violations += (int) floor($record->curTickTotal / Server::TARGET_NANOSECONDS_PER_TICK); } - if($record->curTickTotal > $record->peakTime){ - $record->peakTime = $record->curTickTotal; - } $record->curTickTotal = 0; $record->curCount = 0; $record->ticksActive++; @@ -126,7 +123,7 @@ final class TimingsRecord{ public function getTicksActive() : int{ return $this->ticksActive; } - public function getPeakTime() : float{ return $this->peakTime; } + public function getPeakTime() : int{ return $this->peakTime; } public function startTiming(int $now) : void{ $this->start = $now; @@ -152,6 +149,9 @@ final class TimingsRecord{ ++$this->curCount; ++$this->count; $this->start = 0; + if($diff > $this->peakTime){ + $this->peakTime = $diff; + } } public static function getCurrentRecord() : ?self{