Fixed incorrect implementation of peak timings

This commit is contained in:
Dylan K. Taylor 2023-05-07 18:29:37 +01:00
parent 283ff28aa9
commit fdb3a5b121
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
2 changed files with 5 additions and 5 deletions

View File

@ -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;

View File

@ -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{