Fixed TimingsHandler depth not getting reset when timings is disabled

When timings was disabled, internalStopTiming is not called, and timer depth is not decremented.
If timings is later reenabled, the next call to internalStartTiming will think the timer is already running, and won't generate any new records for the timer.
This has led to broken timings reports with missing Full Server Tick entries, amongst other things.
This commit is contained in:
Dylan K. Taylor
2023-05-06 16:56:39 +01:00
parent 4caa2c7690
commit fa715a074a
2 changed files with 8 additions and 4 deletions

View File

@@ -111,7 +111,7 @@ class TimingsHandler{
}
public static function reload() : void{
TimingsRecord::clearRecords();
TimingsRecord::reset();
if(self::$enabled){
self::$timingStart = hrtime(true);
}
@@ -219,8 +219,9 @@ class TimingsHandler{
/**
* @internal
*/
public function destroyCycles() : void{
public function reset() : void{
$this->rootRecord = null;
$this->recordsByParent = [];
$this->timingDepth = 0;
}
}

View File

@@ -42,9 +42,12 @@ final class TimingsRecord{
private static ?self $currentRecord = null;
public static function clearRecords() : void{
/**
* @internal
*/
public static function reset() : void{
foreach(self::$records as $record){
$record->handler->destroyCycles();
$record->handler->reset();
}
self::$records = [];
self::$currentRecord = null;