mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-09 23:39:43 +00:00
Merge commit 'cef77907c6b21e1fb167bc3085d00a5b1e740813'
# Conflicts: # resources/vanilla # src/timings/TimingsHandler.php
This commit is contained in:
commit
d25e0c3d98
@ -156,34 +156,43 @@ class TimingsHandler{
|
||||
|
||||
self::$HANDLERS[spl_object_id($this)] = $this;
|
||||
}
|
||||
|
||||
public function startTiming() : void{
|
||||
if(self::$enabled and ++$this->timingDepth === 1){
|
||||
$this->start = microtime(true);
|
||||
if($this->parent !== null and ++$this->parent->timingDepth === 1){
|
||||
$this->parent->start = $this->start;
|
||||
if(self::$enabled){
|
||||
$this->internalStartTiming(microtime(true));
|
||||
}
|
||||
}
|
||||
|
||||
private function internalStartTiming(float $now) : void{
|
||||
if(++$this->timingDepth === 1){
|
||||
$this->start = $now;
|
||||
if($this->parent !== null){
|
||||
$this->parent->internalStartTiming($now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function stopTiming() : void{
|
||||
if(self::$enabled){
|
||||
if($this->timingDepth === 0){
|
||||
throw new \InvalidStateException("Cannot stop a timer that is not running");
|
||||
}
|
||||
if(--$this->timingDepth !== 0 or $this->start == 0){
|
||||
return;
|
||||
}
|
||||
$this->internalStopTiming(microtime(true));
|
||||
}
|
||||
}
|
||||
|
||||
$diff = microtime(true) - $this->start;
|
||||
$this->totalTime += $diff;
|
||||
$this->curTickTotal += $diff;
|
||||
++$this->curCount;
|
||||
++$this->count;
|
||||
$this->start = 0;
|
||||
if($this->parent !== null){
|
||||
$this->parent->stopTiming();
|
||||
}
|
||||
private function internalStopTiming(float $now) : void{
|
||||
if($this->timingDepth === 0){
|
||||
throw new \InvalidStateException("Cannot stop a timer that is not running");
|
||||
}
|
||||
if(--$this->timingDepth !== 0 or $this->start == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
$diff = $now - $this->start;
|
||||
$this->totalTime += $diff;
|
||||
$this->curTickTotal += $diff;
|
||||
++$this->curCount;
|
||||
++$this->count;
|
||||
$this->start = 0;
|
||||
if($this->parent !== null){
|
||||
$this->parent->internalStopTiming($now);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user