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