mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 16:49:53 +00:00
Timings: record peak tick time and active ticks
this information is useful for determining the sizes of lag spikes, and giving more accurate average times.
This commit is contained in:
parent
734adec90d
commit
bf84caa02c
@ -58,7 +58,9 @@ class TimingsHandler{
|
|||||||
"Violations: " . $timings->getViolations(),
|
"Violations: " . $timings->getViolations(),
|
||||||
"RecordId: " . $timings->getId(),
|
"RecordId: " . $timings->getId(),
|
||||||
"ParentRecordId: " . ($timings->getParentId() ?? "none"),
|
"ParentRecordId: " . ($timings->getParentId() ?? "none"),
|
||||||
"TimerId: " . $timings->getTimerId()
|
"TimerId: " . $timings->getTimerId(),
|
||||||
|
"Ticks: " . $timings->getTicksActive(),
|
||||||
|
"Peak: " . $timings->getPeakTime(),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
$result = [];
|
$result = [];
|
||||||
|
@ -59,11 +59,17 @@ final class TimingsRecord{
|
|||||||
public static function tick(bool $measure = true) : void{
|
public static function tick(bool $measure = true) : void{
|
||||||
if($measure){
|
if($measure){
|
||||||
foreach(self::$records as $record){
|
foreach(self::$records as $record){
|
||||||
|
if($record->curCount > 0){
|
||||||
if($record->curTickTotal > Server::TARGET_NANOSECONDS_PER_TICK){
|
if($record->curTickTotal > Server::TARGET_NANOSECONDS_PER_TICK){
|
||||||
$record->violations += (int) floor($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->curTickTotal = 0;
|
||||||
$record->curCount = 0;
|
$record->curCount = 0;
|
||||||
|
$record->ticksActive++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
foreach(self::$records as $record){
|
foreach(self::$records as $record){
|
||||||
@ -82,6 +88,8 @@ final class TimingsRecord{
|
|||||||
private int $totalTime = 0;
|
private int $totalTime = 0;
|
||||||
private int $curTickTotal = 0;
|
private int $curTickTotal = 0;
|
||||||
private int $violations = 0;
|
private int $violations = 0;
|
||||||
|
private int $ticksActive = 0;
|
||||||
|
private int $peakTime = 0;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
//I'm not the biggest fan of this cycle, but it seems to be the most effective way to avoid leaking anything.
|
//I'm not the biggest fan of this cycle, but it seems to be the most effective way to avoid leaking anything.
|
||||||
@ -113,6 +121,10 @@ final class TimingsRecord{
|
|||||||
|
|
||||||
public function getViolations() : int{ return $this->violations; }
|
public function getViolations() : int{ return $this->violations; }
|
||||||
|
|
||||||
|
public function getTicksActive() : int{ return $this->ticksActive; }
|
||||||
|
|
||||||
|
public function getPeakTime() : float{ return $this->peakTime; }
|
||||||
|
|
||||||
public function startTiming(int $now) : void{
|
public function startTiming(int $now) : void{
|
||||||
$this->start = $now;
|
$this->start = $now;
|
||||||
self::$currentRecord = $this;
|
self::$currentRecord = $this;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user