mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-03 00:29:54 +00:00
TPS measurement improvement, moved interface handling to tick
This commit is contained in:
parent
317c6788a6
commit
57373b8c5e
@ -127,8 +127,7 @@ class Server{
|
|||||||
*/
|
*/
|
||||||
private $tickCounter;
|
private $tickCounter;
|
||||||
private $nextTick = 0;
|
private $nextTick = 0;
|
||||||
private $tickAverage = [20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20];
|
private $tickAverage = [20,20,20,20,20,20,20,20,20,20];
|
||||||
private $tickTime = 0;
|
|
||||||
private $inTick = false;
|
private $inTick = false;
|
||||||
|
|
||||||
/** @var \AttachableThreadedLogger */
|
/** @var \AttachableThreadedLogger */
|
||||||
@ -1928,19 +1927,7 @@ class Server{
|
|||||||
|
|
||||||
private function tickProcessor(){
|
private function tickProcessor(){
|
||||||
$lastLoop = 0;
|
$lastLoop = 0;
|
||||||
$connectionTimer = Timings::$connectionTimer;
|
|
||||||
while($this->isRunning){
|
while($this->isRunning){
|
||||||
//TODO: move this to tick
|
|
||||||
$connectionTimer->startTiming();
|
|
||||||
foreach($this->interfaces as $interface){
|
|
||||||
if($interface->process()){
|
|
||||||
$lastLoop = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$connectionTimer->stopTiming();
|
|
||||||
|
|
||||||
$this->generationManager->handlePackets();
|
|
||||||
|
|
||||||
++$lastLoop;
|
++$lastLoop;
|
||||||
|
|
||||||
if(($ticks = $this->tick()) !== true){
|
if(($ticks = $this->tick()) !== true){
|
||||||
@ -2045,6 +2032,14 @@ class Server{
|
|||||||
++$this->tickCounter;
|
++$this->tickCounter;
|
||||||
|
|
||||||
$this->checkConsole();
|
$this->checkConsole();
|
||||||
|
|
||||||
|
//TODO: move this to tick
|
||||||
|
Timings::$connectionTimer->startTiming();
|
||||||
|
foreach($this->interfaces as $interface){
|
||||||
|
$interface->process();
|
||||||
|
}
|
||||||
|
Timings::$connectionTimer->stopTiming();
|
||||||
|
|
||||||
Timings::$schedulerTimer->startTiming();
|
Timings::$schedulerTimer->startTiming();
|
||||||
$this->scheduler->mainThreadHeartbeat($this->tickCounter);
|
$this->scheduler->mainThreadHeartbeat($this->tickCounter);
|
||||||
Timings::$schedulerTimer->stopTiming();
|
Timings::$schedulerTimer->stopTiming();
|
||||||
@ -2057,17 +2052,15 @@ class Server{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->generationManager->handlePackets();
|
||||||
|
|
||||||
Timings::$serverTickTimer->stopTiming();
|
Timings::$serverTickTimer->stopTiming();
|
||||||
|
|
||||||
TimingsHandler::tick();
|
TimingsHandler::tick();
|
||||||
|
|
||||||
$now = microtime(true);
|
$now = microtime(true);
|
||||||
$updateTime = max(0.01, $tickTime - $this->tickTime);
|
|
||||||
|
|
||||||
array_shift($this->tickAverage);
|
array_shift($this->tickAverage);
|
||||||
$this->tickAverage[] = 1 / $updateTime;
|
$this->tickAverage[] = min(20, 1 / ($now - $tickTime));
|
||||||
|
|
||||||
$this->tickTime = $tickTime;
|
|
||||||
|
|
||||||
if(($this->nextTick - $tickTime) < -1){
|
if(($this->nextTick - $tickTime) < -1){
|
||||||
$this->nextTick = $tickTime;
|
$this->nextTick = $tickTime;
|
||||||
|
@ -934,7 +934,7 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
new Double("", $source->getY()),
|
new Double("", $source->getY()),
|
||||||
new Double("", $source->getZ())
|
new Double("", $source->getZ())
|
||||||
]),
|
]),
|
||||||
//TODO: add random motion with physics
|
|
||||||
"Motion" => new Enum("Motion", [
|
"Motion" => new Enum("Motion", [
|
||||||
new Double("", $motion->x),
|
new Double("", $motion->x),
|
||||||
new Double("", $motion->y),
|
new Double("", $motion->y),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user