TPS measurement improvement, moved interface handling to tick

This commit is contained in:
Shoghi Cervantes 2014-09-09 18:07:27 +02:00
parent 317c6788a6
commit 57373b8c5e
2 changed files with 13 additions and 20 deletions

View File

@ -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;

View File

@ -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),