diff --git a/src/MemoryManager.php b/src/MemoryManager.php index 0dcafa1c3..162533903 100644 --- a/src/MemoryManager.php +++ b/src/MemoryManager.php @@ -228,7 +228,7 @@ class MemoryManager{ * Called every tick to update the memory manager state. */ public function check() : void{ - Timings::$memoryManagerTimer->startTiming(); + Timings::$memoryManager->startTiming(); if(($this->memoryLimit > 0 or $this->globalMemoryLimit > 0) and ++$this->checkTicker >= $this->checkRate){ $this->checkTicker = 0; @@ -261,11 +261,11 @@ class MemoryManager{ $this->triggerGarbageCollector(); } - Timings::$memoryManagerTimer->stopTiming(); + Timings::$memoryManager->stopTiming(); } public function triggerGarbageCollector() : int{ - Timings::$garbageCollectorTimer->startTiming(); + Timings::$garbageCollector->startTiming(); if($this->garbageCollectionAsync){ $pool = $this->server->getAsyncPool(); @@ -280,7 +280,7 @@ class MemoryManager{ $cycles = gc_collect_cycles(); gc_mem_caches(); - Timings::$garbageCollectorTimer->stopTiming(); + Timings::$garbageCollector->stopTiming(); return $cycles; } diff --git a/src/Server.php b/src/Server.php index 9de0e7a32..5280bb482 100644 --- a/src/Server.php +++ b/src/Server.php @@ -1079,11 +1079,11 @@ class Server{ $consoleNotifier = new SleeperNotifier(); $this->console = new CommandReader($consoleNotifier); $this->tickSleeper->addNotifier($consoleNotifier, function() use ($consoleSender) : void{ - Timings::$serverCommandTimer->startTiming(); + Timings::$serverCommand->startTiming(); while(($line = $this->console->getLine()) !== null){ $this->dispatchCommand($consoleSender, $line); } - Timings::$serverCommandTimer->stopTiming(); + Timings::$serverCommand->stopTiming(); }); $this->console->start(PTHREADS_INHERIT_NONE); @@ -1255,7 +1255,7 @@ class Server{ */ public function prepareBatch(PacketBatch $stream, Compressor $compressor, ?bool $sync = null) : CompressBatchPromise{ try{ - Timings::$playerNetworkSendCompressTimer->startTiming(); + Timings::$playerNetworkSendCompress->startTiming(); $buffer = $stream->getBuffer(); @@ -1273,7 +1273,7 @@ class Server{ return $promise; }finally{ - Timings::$playerNetworkSendCompressTimer->stopTiming(); + Timings::$playerNetworkSendCompress->stopTiming(); } } @@ -1595,7 +1595,7 @@ class Server{ } private function titleTick() : void{ - Timings::$titleTickTimer->startTiming(); + Timings::$titleTick->startTiming(); $d = Process::getRealMemoryUsage(); $u = Process::getAdvancedMemoryUsage(); @@ -1615,7 +1615,7 @@ class Server{ " kB/s | TPS " . $this->getTicksPerSecondAverage() . " | Load " . $this->getTickUsageAverage() . "%\x07"; - Timings::$titleTickTimer->stopTiming(); + Timings::$titleTick->stopTiming(); } /** @@ -1627,23 +1627,23 @@ class Server{ return; } - Timings::$serverTickTimer->startTiming(); + Timings::$serverTick->startTiming(); ++$this->tickCounter; - Timings::$schedulerTimer->startTiming(); + Timings::$scheduler->startTiming(); $this->pluginManager->tickSchedulers($this->tickCounter); - Timings::$schedulerTimer->stopTiming(); + Timings::$scheduler->stopTiming(); - Timings::$schedulerAsyncTimer->startTiming(); + Timings::$schedulerAsync->startTiming(); $this->asyncPool->collectTasks(); - Timings::$schedulerAsyncTimer->stopTiming(); + Timings::$schedulerAsync->stopTiming(); $this->worldManager->tick($this->tickCounter); - Timings::$connectionTimer->startTiming(); + Timings::$connection->startTiming(); $this->network->tick(); - Timings::$connectionTimer->stopTiming(); + Timings::$connection->stopTiming(); if(($this->tickCounter % 20) === 0){ if($this->doTitleTick){ @@ -1677,7 +1677,7 @@ class Server{ $this->getMemoryManager()->check(); - Timings::$serverTickTimer->stopTiming(); + Timings::$serverTick->stopTiming(); $now = microtime(true); $this->currentTPS = min(20, 1 / max(0.001, $now - $tickTime)); diff --git a/src/entity/Entity.php b/src/entity/Entity.php index ce18440ab..a84c74245 100644 --- a/src/entity/Entity.php +++ b/src/entity/Entity.php @@ -959,9 +959,9 @@ abstract class Entity{ $this->updateMovement(); - Timings::$timerEntityBaseTick->startTiming(); + Timings::$entityBaseTick->startTiming(); $hasUpdate = $this->entityBaseTick($tickDiff); - Timings::$timerEntityBaseTick->stopTiming(); + Timings::$entityBaseTick->stopTiming(); $this->timings->stopTiming(); @@ -1073,7 +1073,7 @@ abstract class Entity{ protected function move(float $dx, float $dy, float $dz) : void{ $this->blocksAround = null; - Timings::$entityMoveTimer->startTiming(); + Timings::$entityMove->startTiming(); $movX = $dx; $movY = $dy; @@ -1219,7 +1219,7 @@ abstract class Entity{ //TODO: vehicle collision events (first we need to spawn them!) - Timings::$entityMoveTimer->stopTiming(); + Timings::$entityMove->stopTiming(); } protected function checkGroundState(float $movX, float $movY, float $movZ, float $dx, float $dy, float $dz) : void{ diff --git a/src/entity/Living.php b/src/entity/Living.php index 8475983ec..08890698e 100644 --- a/src/entity/Living.php +++ b/src/entity/Living.php @@ -552,7 +552,7 @@ abstract class Living extends Entity{ } protected function entityBaseTick(int $tickDiff = 1) : bool{ - Timings::$timerLivingEntityBaseTick->startTiming(); + Timings::$livingEntityBaseTick->startTiming(); $hasUpdate = parent::entityBaseTick($tickDiff); @@ -576,7 +576,7 @@ abstract class Living extends Entity{ $this->attackTime -= $tickDiff; } - Timings::$timerLivingEntityBaseTick->stopTiming(); + Timings::$livingEntityBaseTick->stopTiming(); return $hasUpdate; } diff --git a/src/entity/projectile/Projectile.php b/src/entity/projectile/Projectile.php index c95c38ff0..944728452 100644 --- a/src/entity/projectile/Projectile.php +++ b/src/entity/projectile/Projectile.php @@ -173,7 +173,7 @@ abstract class Projectile extends Entity{ public function move(float $dx, float $dy, float $dz) : void{ $this->blocksAround = null; - Timings::$entityMoveTimer->startTiming(); + Timings::$entityMove->startTiming(); $start = $this->location->asVector3(); $end = $start->addVector($this->motion); @@ -264,7 +264,7 @@ abstract class Projectile extends Entity{ $this->getWorld()->onEntityMoved($this); $this->checkBlockCollision(); - Timings::$entityMoveTimer->stopTiming(); + Timings::$entityMove->stopTiming(); } /** diff --git a/src/network/mcpe/NetworkSession.php b/src/network/mcpe/NetworkSession.php index f1a298c6a..33db8255d 100644 --- a/src/network/mcpe/NetworkSession.php +++ b/src/network/mcpe/NetworkSession.php @@ -316,25 +316,25 @@ class NetworkSession{ } if($this->cipher !== null){ - Timings::$playerNetworkReceiveDecryptTimer->startTiming(); + Timings::$playerNetworkReceiveDecrypt->startTiming(); try{ $payload = $this->cipher->decrypt($payload); }catch(DecryptionException $e){ $this->logger->debug("Encrypted packet: " . base64_encode($payload)); throw BadPacketException::wrap($e, "Packet decryption error"); }finally{ - Timings::$playerNetworkReceiveDecryptTimer->stopTiming(); + Timings::$playerNetworkReceiveDecrypt->stopTiming(); } } - Timings::$playerNetworkReceiveDecompressTimer->startTiming(); + Timings::$playerNetworkReceiveDecompress->startTiming(); try{ $stream = new PacketBatch($this->compressor->decompress($payload)); }catch(DecompressionException $e){ $this->logger->debug("Failed to decompress packet: " . base64_encode($payload)); throw BadPacketException::wrap($e, "Compressed packet batch decode error"); }finally{ - Timings::$playerNetworkReceiveDecompressTimer->stopTiming(); + Timings::$playerNetworkReceiveDecompress->stopTiming(); } try{ @@ -484,9 +484,9 @@ class NetworkSession{ private function sendEncoded(string $payload, bool $immediate = false) : void{ if($this->cipher !== null){ - Timings::$playerNetworkSendEncryptTimer->startTiming(); + Timings::$playerNetworkSendEncrypt->startTiming(); $payload = $this->cipher->encrypt($payload); - Timings::$playerNetworkSendEncryptTimer->stopTiming(); + Timings::$playerNetworkSendEncrypt->stopTiming(); } $this->sender->send($payload, $immediate); } @@ -859,12 +859,12 @@ class NetworkSession{ $this->logger->debug("Tried to send no-longer-active chunk $chunkX $chunkZ in world " . $world->getFolderName()); return; } - $currentWorld->timings->syncChunkSendTimer->startTiming(); + $currentWorld->timings->syncChunkSend->startTiming(); try{ $this->queueCompressed($promise); $onCompletion($chunkX, $chunkZ); }finally{ - $currentWorld->timings->syncChunkSendTimer->stopTiming(); + $currentWorld->timings->syncChunkSend->stopTiming(); } } ); diff --git a/src/network/mcpe/cache/ChunkCache.php b/src/network/mcpe/cache/ChunkCache.php index 8dd8b8515..dd2f4503f 100644 --- a/src/network/mcpe/cache/ChunkCache.php +++ b/src/network/mcpe/cache/ChunkCache.php @@ -107,7 +107,7 @@ class ChunkCache implements ChunkListener{ ++$this->misses; - $this->world->timings->syncChunkSendPrepareTimer->startTiming(); + $this->world->timings->syncChunkSendPrepare->startTiming(); try{ $this->caches[$chunkHash] = new CompressBatchPromise(); @@ -128,7 +128,7 @@ class ChunkCache implements ChunkListener{ return $this->caches[$chunkHash]; }finally{ - $this->world->timings->syncChunkSendPrepareTimer->stopTiming(); + $this->world->timings->syncChunkSendPrepare->stopTiming(); } } diff --git a/src/network/mcpe/cache/CraftingDataCache.php b/src/network/mcpe/cache/CraftingDataCache.php index 68e157499..55aa2c1f3 100644 --- a/src/network/mcpe/cache/CraftingDataCache.php +++ b/src/network/mcpe/cache/CraftingDataCache.php @@ -67,7 +67,7 @@ final class CraftingDataCache{ * Rebuilds the cached CraftingDataPacket. */ private function buildCraftingDataCache(CraftingManager $manager) : CraftingDataPacket{ - Timings::$craftingDataCacheRebuildTimer->startTiming(); + Timings::$craftingDataCacheRebuild->startTiming(); $pk = new CraftingDataPacket(); $pk->cleanRecipes = true; @@ -127,7 +127,7 @@ final class CraftingDataCache{ ); } - Timings::$craftingDataCacheRebuildTimer->stopTiming(); + Timings::$craftingDataCacheRebuild->stopTiming(); return $pk; } } diff --git a/src/permission/PermissibleBase.php b/src/permission/PermissibleBase.php index 3cff6afc1..0f8f82163 100644 --- a/src/permission/PermissibleBase.php +++ b/src/permission/PermissibleBase.php @@ -130,7 +130,7 @@ class PermissibleBase implements Permissible{ } public function recalculatePermissions() : array{ - Timings::$permissibleCalculationTimer->startTiming(); + Timings::$permissibleCalculation->startTiming(); $permManager = PermissionManager::getInstance(); $permManager->unsubscribeFromAllPermissions($this); @@ -152,7 +152,7 @@ class PermissibleBase implements Permissible{ } $diff = []; - Timings::$permissibleCalculationDiffTimer->time(function() use ($oldPermissions, &$diff) : void{ + Timings::$permissibleCalculationDiff->time(function() use ($oldPermissions, &$diff) : void{ foreach($this->permissions as $permissionAttachmentInfo){ $name = $permissionAttachmentInfo->getPermission(); if(!isset($oldPermissions[$name])){ @@ -168,7 +168,7 @@ class PermissibleBase implements Permissible{ } }); - Timings::$permissibleCalculationCallbackTimer->time(function() use ($diff) : void{ + Timings::$permissibleCalculationCallback->time(function() use ($diff) : void{ if(count($diff) > 0){ foreach($this->permissionRecalculationCallbacks as $closure){ $closure($diff); @@ -176,7 +176,7 @@ class PermissibleBase implements Permissible{ } }); - Timings::$permissibleCalculationTimer->stopTiming(); + Timings::$permissibleCalculation->stopTiming(); return $diff; } diff --git a/src/player/Player.php b/src/player/Player.php index 03fc38a7a..c60db4b12 100644 --- a/src/player/Player.php +++ b/src/player/Player.php @@ -708,7 +708,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ return; } - Timings::$playerChunkSendTimer->startTiming(); + Timings::$playerChunkSend->startTiming(); $count = 0; foreach($this->loadQueue as $index => $distance){ @@ -753,7 +753,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ }); } - Timings::$playerChunkSendTimer->stopTiming(); + Timings::$playerChunkSend->stopTiming(); } private function recheckBroadcastPermissions() : void{ @@ -814,7 +814,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ return; } - Timings::$playerChunkOrderTimer->startTiming(); + Timings::$playerChunkOrder->startTiming(); $newOrder = []; $unloadChunks = $this->usedChunks; @@ -841,7 +841,7 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->networkSession->syncViewAreaCenterPoint($this->location, $this->viewDistance); } - Timings::$playerChunkOrderTimer->stopTiming(); + Timings::$playerChunkOrder->stopTiming(); } /** @@ -1299,14 +1299,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ $this->inAirTicks += $tickDiff; } - Timings::$timerEntityBaseTick->startTiming(); + Timings::$entityBaseTick->startTiming(); $this->entityBaseTick($tickDiff); - Timings::$timerEntityBaseTick->stopTiming(); + Timings::$entityBaseTick->stopTiming(); if(!$this->isSpectator() and $this->isAlive()){ - Timings::$playerCheckNearEntitiesTimer->startTiming(); + Timings::$playerCheckNearEntities->startTiming(); $this->checkNearEntities(); - Timings::$playerCheckNearEntitiesTimer->stopTiming(); + Timings::$playerCheckNearEntities->stopTiming(); } if($this->blockBreakHandler !== null and !$this->blockBreakHandler->update()){ @@ -1362,9 +1362,9 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{ } if(strpos($ev->getMessage(), "/") === 0){ - Timings::$playerCommandTimer->startTiming(); + Timings::$playerCommand->startTiming(); $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1)); - Timings::$playerCommandTimer->stopTiming(); + Timings::$playerCommand->stopTiming(); }else{ $ev = new PlayerChatEvent($this, $ev->getMessage(), $this->server->getBroadcastChannelSubscribers(Server::BROADCAST_CHANNEL_USERS)); $ev->call(); diff --git a/src/timings/Timings.php b/src/timings/Timings.php index 586a0c1a6..c0176cc60 100644 --- a/src/timings/Timings.php +++ b/src/timings/Timings.php @@ -38,76 +38,76 @@ abstract class Timings{ private static $initialized = false; /** @var TimingsHandler */ - public static $fullTickTimer; + public static $fullTick; /** @var TimingsHandler */ - public static $serverTickTimer; + public static $serverTick; /** @var TimingsHandler */ - public static $memoryManagerTimer; + public static $memoryManager; /** @var TimingsHandler */ - public static $garbageCollectorTimer; + public static $garbageCollector; /** @var TimingsHandler */ - public static $titleTickTimer; + public static $titleTick; /** @var TimingsHandler */ - public static $playerNetworkSendTimer; + public static $playerNetworkSend; /** @var TimingsHandler */ - public static $playerNetworkSendCompressTimer; + public static $playerNetworkSendCompress; /** @var TimingsHandler */ - public static $playerNetworkSendEncryptTimer; + public static $playerNetworkSendEncrypt; /** @var TimingsHandler */ - public static $playerNetworkReceiveTimer; + public static $playerNetworkReceive; /** @var TimingsHandler */ - public static $playerNetworkReceiveDecompressTimer; + public static $playerNetworkReceiveDecompress; /** @var TimingsHandler */ - public static $playerNetworkReceiveDecryptTimer; + public static $playerNetworkReceiveDecrypt; /** @var TimingsHandler */ - public static $playerChunkOrderTimer; + public static $playerChunkOrder; /** @var TimingsHandler */ - public static $playerChunkSendTimer; + public static $playerChunkSend; /** @var TimingsHandler */ - public static $connectionTimer; + public static $connection; /** @var TimingsHandler */ - public static $schedulerTimer; + public static $scheduler; /** @var TimingsHandler */ - public static $serverCommandTimer; + public static $serverCommand; /** @var TimingsHandler */ - public static $worldLoadTimer; + public static $worldLoad; /** @var TimingsHandler */ - public static $worldSaveTimer; + public static $worldSave; /** @var TimingsHandler */ - public static $populationTimer; + public static $population; /** @var TimingsHandler */ - public static $generationCallbackTimer; + public static $generationCallback; /** @var TimingsHandler */ - public static $permissibleCalculationTimer; + public static $permissibleCalculation; /** @var TimingsHandler */ - public static $permissibleCalculationDiffTimer; + public static $permissibleCalculationDiff; /** @var TimingsHandler */ - public static $permissibleCalculationCallbackTimer; + public static $permissibleCalculationCallback; /** @var TimingsHandler */ - public static $entityMoveTimer; + public static $entityMove; /** @var TimingsHandler */ - public static $playerCheckNearEntitiesTimer; + public static $playerCheckNearEntities; /** @var TimingsHandler */ - public static $tickEntityTimer; + public static $tickEntity; /** @var TimingsHandler */ - public static $tickTileEntityTimer; + public static $tickTileEntity; /** @var TimingsHandler */ - public static $timerEntityBaseTick; + public static $entityBaseTick; /** @var TimingsHandler */ - public static $timerLivingEntityBaseTick; + public static $livingEntityBaseTick; /** @var TimingsHandler */ - public static $schedulerSyncTimer; + public static $schedulerSync; /** @var TimingsHandler */ - public static $schedulerAsyncTimer; + public static $schedulerAsync; /** @var TimingsHandler */ - public static $playerCommandTimer; + public static $playerCommand; /** @var TimingsHandler */ - public static $craftingDataCacheRebuildTimer; + public static $craftingDataCacheRebuild; /** @var TimingsHandler */ public static $syncPlayerDataLoad; @@ -134,51 +134,51 @@ abstract class Timings{ } self::$initialized = true; - self::$fullTickTimer = new TimingsHandler("Full Server Tick"); - self::$serverTickTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Full Server Tick", self::$fullTickTimer); - self::$memoryManagerTimer = new TimingsHandler("Memory Manager"); - self::$garbageCollectorTimer = new TimingsHandler("Garbage Collector", self::$memoryManagerTimer); - self::$titleTickTimer = new TimingsHandler("Console Title Tick"); + self::$fullTick = new TimingsHandler("Full Server Tick"); + self::$serverTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Full Server Tick", self::$fullTick); + self::$memoryManager = new TimingsHandler("Memory Manager"); + self::$garbageCollector = new TimingsHandler("Garbage Collector", self::$memoryManager); + self::$titleTick = new TimingsHandler("Console Title Tick"); - self::$playerNetworkSendTimer = new TimingsHandler("Player Network Send"); - self::$playerNetworkSendCompressTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Compression", self::$playerNetworkSendTimer); - self::$playerNetworkSendEncryptTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Encryption", self::$playerNetworkSendTimer); + self::$playerNetworkSend = new TimingsHandler("Player Network Send"); + self::$playerNetworkSendCompress = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Compression", self::$playerNetworkSend); + self::$playerNetworkSendEncrypt = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Send - Encryption", self::$playerNetworkSend); - self::$playerNetworkReceiveTimer = new TimingsHandler("Player Network Receive"); - self::$playerNetworkReceiveDecompressTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Receive - Decompression", self::$playerNetworkReceiveTimer); - self::$playerNetworkReceiveDecryptTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Receive - Decryption", self::$playerNetworkReceiveTimer); + self::$playerNetworkReceive = new TimingsHandler("Player Network Receive"); + self::$playerNetworkReceiveDecompress = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Receive - Decompression", self::$playerNetworkReceive); + self::$playerNetworkReceiveDecrypt = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Player Network Receive - Decryption", self::$playerNetworkReceive); - self::$broadcastPackets = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Broadcast Packets", self::$playerNetworkSendTimer); + self::$broadcastPackets = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Broadcast Packets", self::$playerNetworkSend); - self::$playerChunkOrderTimer = new TimingsHandler("Player Order Chunks"); - self::$playerChunkSendTimer = new TimingsHandler("Player Send Chunks"); - self::$connectionTimer = new TimingsHandler("Connection Handler"); - self::$schedulerTimer = new TimingsHandler("Scheduler"); - self::$serverCommandTimer = new TimingsHandler("Server Command"); - self::$worldLoadTimer = new TimingsHandler("World Load"); - self::$worldSaveTimer = new TimingsHandler("World Save"); - self::$populationTimer = new TimingsHandler("World Population"); - self::$generationCallbackTimer = new TimingsHandler("World Generation Callback"); - self::$permissibleCalculationTimer = new TimingsHandler("Permissible Calculation"); - self::$permissibleCalculationDiffTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Permissible Calculation - Diff", self::$permissibleCalculationTimer); - self::$permissibleCalculationCallbackTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Permissible Calculation - Callbacks", self::$permissibleCalculationTimer); + self::$playerChunkOrder = new TimingsHandler("Player Order Chunks"); + self::$playerChunkSend = new TimingsHandler("Player Send Chunks"); + self::$connection = new TimingsHandler("Connection Handler"); + self::$scheduler = new TimingsHandler("Scheduler"); + self::$serverCommand = new TimingsHandler("Server Command"); + self::$worldLoad = new TimingsHandler("World Load"); + self::$worldSave = new TimingsHandler("World Save"); + self::$population = new TimingsHandler("World Population"); + self::$generationCallback = new TimingsHandler("World Generation Callback"); + self::$permissibleCalculation = new TimingsHandler("Permissible Calculation"); + self::$permissibleCalculationDiff = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Permissible Calculation - Diff", self::$permissibleCalculation); + self::$permissibleCalculationCallback = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Permissible Calculation - Callbacks", self::$permissibleCalculation); self::$syncPlayerDataLoad = new TimingsHandler("Player Data Load"); self::$syncPlayerDataSave = new TimingsHandler("Player Data Save"); - self::$entityMoveTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "entityMove"); - self::$playerCheckNearEntitiesTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "checkNearEntities"); - self::$tickEntityTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity"); - self::$tickTileEntityTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickTileEntity"); + self::$entityMove = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "entityMove"); + self::$playerCheckNearEntities = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "checkNearEntities"); + self::$tickEntity = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity"); + self::$tickTileEntity = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickTileEntity"); - self::$timerEntityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "entityBaseTick"); - self::$timerLivingEntityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "livingEntityBaseTick"); + self::$entityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "entityBaseTick"); + self::$livingEntityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "livingEntityBaseTick"); - self::$schedulerSyncTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Scheduler - Sync Tasks"); - self::$schedulerAsyncTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Scheduler - Async Tasks"); + self::$schedulerSync = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Scheduler - Sync Tasks"); + self::$schedulerAsync = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Scheduler - Async Tasks"); - self::$playerCommandTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "playerCommand"); - self::$craftingDataCacheRebuildTimer = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "craftingDataCacheRebuild"); + self::$playerCommand = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "playerCommand"); + self::$craftingDataCacheRebuild = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "craftingDataCacheRebuild"); } @@ -192,7 +192,7 @@ abstract class Timings{ } if(!isset(self::$pluginTaskTimingMap[$name])){ - self::$pluginTaskTimingMap[$name] = new TimingsHandler($name, self::$schedulerSyncTimer); + self::$pluginTaskTimingMap[$name] = new TimingsHandler($name, self::$schedulerSync); } return self::$pluginTaskTimingMap[$name]; @@ -202,9 +202,9 @@ abstract class Timings{ $entityType = (new \ReflectionClass($entity))->getShortName(); if(!isset(self::$entityTypeTimingMap[$entityType])){ if($entity instanceof Player){ - self::$entityTypeTimingMap[$entityType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity - EntityPlayer", self::$tickEntityTimer); + self::$entityTypeTimingMap[$entityType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity - EntityPlayer", self::$tickEntity); }else{ - self::$entityTypeTimingMap[$entityType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity - " . $entityType, self::$tickEntityTimer); + self::$entityTypeTimingMap[$entityType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickEntity - " . $entityType, self::$tickEntity); } } @@ -214,7 +214,7 @@ abstract class Timings{ public static function getTileEntityTimings(Tile $tile) : TimingsHandler{ $tileType = (new \ReflectionClass($tile))->getShortName(); if(!isset(self::$tileEntityTypeTimingMap[$tileType])){ - self::$tileEntityTypeTimingMap[$tileType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickTileEntity - " . $tileType, self::$tickTileEntityTimer); + self::$tileEntityTypeTimingMap[$tileType] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "tickTileEntity - " . $tileType, self::$tickTileEntity); } return self::$tileEntityTypeTimingMap[$tileType]; @@ -224,7 +224,7 @@ abstract class Timings{ $pid = $pk->pid(); if(!isset(self::$packetReceiveTimingMap[$pid])){ $pkName = (new \ReflectionClass($pk))->getShortName(); - self::$packetReceiveTimingMap[$pid] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "receivePacket - " . $pkName . " [0x" . dechex($pid) . "]", self::$playerNetworkReceiveTimer); + self::$packetReceiveTimingMap[$pid] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "receivePacket - " . $pkName . " [0x" . dechex($pid) . "]", self::$playerNetworkReceive); } return self::$packetReceiveTimingMap[$pid]; @@ -234,7 +234,7 @@ abstract class Timings{ $pid = $pk->pid(); if(!isset(self::$packetSendTimingMap[$pid])){ $pkName = (new \ReflectionClass($pk))->getShortName(); - self::$packetSendTimingMap[$pid] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "sendPacket - " . $pkName . " [0x" . dechex($pid) . "]", self::$playerNetworkSendTimer); + self::$packetSendTimingMap[$pid] = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "sendPacket - " . $pkName . " [0x" . dechex($pid) . "]", self::$playerNetworkSend); } return self::$packetSendTimingMap[$pid]; diff --git a/src/world/World.php b/src/world/World.php index ada7c3670..944cdecec 100644 --- a/src/world/World.php +++ b/src/world/World.php @@ -787,7 +787,7 @@ class World implements ChunkManager{ $this->timings->entityTick->startTiming(); //Update entities that need update - Timings::$tickEntityTimer->startTiming(); + Timings::$tickEntity->startTiming(); foreach($this->updateEntities as $id => $entity){ if($entity->isClosed() or !$entity->onUpdate($currentTick)){ unset($this->updateEntities[$id]); @@ -796,7 +796,7 @@ class World implements ChunkManager{ $entity->close(); } } - Timings::$tickEntityTimer->stopTiming(); + Timings::$tickEntity->stopTiming(); $this->timings->entityTick->stopTiming(); $this->timings->doTickTiles->startTiming(); @@ -1039,7 +1039,7 @@ class World implements ChunkManager{ } public function saveChunks() : void{ - $this->timings->syncChunkSaveTimer->startTiming(); + $this->timings->syncChunkSave->startTiming(); try{ foreach($this->chunks as $chunkHash => $chunk){ if($chunk->isDirty()){ @@ -1049,7 +1049,7 @@ class World implements ChunkManager{ } } }finally{ - $this->timings->syncChunkSaveTimer->stopTiming(); + $this->timings->syncChunkSave->stopTiming(); } } @@ -1997,7 +1997,7 @@ class World implements ChunkManager{ } public function generateChunkCallback(int $x, int $z, ?Chunk $chunk) : void{ - Timings::$generationCallbackTimer->startTiming(); + Timings::$generationCallback->startTiming(); if(isset($this->chunkPopulationQueue[$index = World::chunkHash($x, $z)])){ for($xx = -1; $xx <= 1; ++$xx){ for($zz = -1; $zz <= 1; ++$zz){ @@ -2025,7 +2025,7 @@ class World implements ChunkManager{ }elseif($chunk !== null){ $this->setChunk($x, $z, $chunk, false); } - Timings::$generationCallbackTimer->stopTiming(); + Timings::$generationCallback->stopTiming(); } /** @@ -2303,11 +2303,11 @@ class World implements ChunkManager{ return $this->chunks[$chunkHash]; } - $this->timings->syncChunkLoadTimer->startTiming(); + $this->timings->syncChunkLoad->startTiming(); $this->cancelUnloadChunkRequest($x, $z); - $this->timings->syncChunkLoadDataTimer->startTiming(); + $this->timings->syncChunkLoadData->startTiming(); $chunk = null; @@ -2317,10 +2317,10 @@ class World implements ChunkManager{ $this->logger->critical("Failed to load chunk x=$x z=$z: " . $e->getMessage()); } - $this->timings->syncChunkLoadDataTimer->stopTiming(); + $this->timings->syncChunkLoadData->stopTiming(); if($chunk === null){ - $this->timings->syncChunkLoadTimer->stopTiming(); + $this->timings->syncChunkLoad->stopTiming(); return null; } @@ -2339,14 +2339,14 @@ class World implements ChunkManager{ $listener->onChunkLoaded($x, $z, $chunk); } - $this->timings->syncChunkLoadTimer->stopTiming(); + $this->timings->syncChunkLoad->stopTiming(); return $chunk; } private function initChunk(int $chunkX, int $chunkZ, Chunk $chunk) : void{ if($chunk->NBTentities !== null){ - $this->timings->syncChunkLoadEntitiesTimer->startTiming(); + $this->timings->syncChunkLoadEntities->startTiming(); $entityFactory = EntityFactory::getInstance(); foreach($chunk->NBTentities as $nbt){ try{ @@ -2370,10 +2370,10 @@ class World implements ChunkManager{ $chunk->setDirtyFlag(Chunk::DIRTY_FLAG_ENTITIES, true); $chunk->NBTentities = null; - $this->timings->syncChunkLoadEntitiesTimer->stopTiming(); + $this->timings->syncChunkLoadEntities->stopTiming(); } if($chunk->NBTtiles !== null){ - $this->timings->syncChunkLoadTileEntitiesTimer->startTiming(); + $this->timings->syncChunkLoadTileEntities->startTiming(); $tileFactory = TileFactory::getInstance(); foreach($chunk->NBTtiles as $nbt){ if(($tile = $tileFactory->createFromData($this, $nbt)) !== null){ @@ -2386,7 +2386,7 @@ class World implements ChunkManager{ $chunk->setDirtyFlag(Chunk::DIRTY_FLAG_TILES, true); $chunk->NBTtiles = null; - $this->timings->syncChunkLoadTileEntitiesTimer->stopTiming(); + $this->timings->syncChunkLoadTileEntities->stopTiming(); } } @@ -2433,11 +2433,11 @@ class World implements ChunkManager{ } if($trySave and $this->getAutoSave() and $chunk->isDirty()){ - $this->timings->syncChunkSaveTimer->startTiming(); + $this->timings->syncChunkSave->startTiming(); try{ $this->provider->saveChunk($x, $z, $chunk); }finally{ - $this->timings->syncChunkSaveTimer->stopTiming(); + $this->timings->syncChunkSave->stopTiming(); } } @@ -2632,7 +2632,7 @@ class World implements ChunkManager{ $chunk = $this->loadChunk($x, $z); if($chunk === null || !$chunk->isPopulated()){ - Timings::$populationTimer->startTiming(); + Timings::$population->startTiming(); $this->chunkPopulationQueue[$index] = true; for($xx = -1; $xx <= 1; ++$xx){ @@ -2648,7 +2648,7 @@ class World implements ChunkManager{ } $this->workerPool->submitTaskToWorker($task, $workerId); - Timings::$populationTimer->stopTiming(); + Timings::$population->stopTiming(); return false; } diff --git a/src/world/WorldManager.php b/src/world/WorldManager.php index 0d70e96f1..fe4f992e1 100644 --- a/src/world/WorldManager.php +++ b/src/world/WorldManager.php @@ -374,7 +374,7 @@ class WorldManager{ } private function doAutoSave() : void{ - Timings::$worldSaveTimer->startTiming(); + Timings::$worldSave->startTiming(); foreach($this->worlds as $world){ foreach($world->getPlayers() as $player){ if($player->spawned){ @@ -383,6 +383,6 @@ class WorldManager{ } $world->save(false); } - Timings::$worldSaveTimer->stopTiming(); + Timings::$worldSave->stopTiming(); } } diff --git a/src/world/WorldTimings.php b/src/world/WorldTimings.php index ddc2203a3..c3e6e98b2 100644 --- a/src/world/WorldTimings.php +++ b/src/world/WorldTimings.php @@ -49,20 +49,20 @@ class WorldTimings{ public $doTick; /** @var TimingsHandler */ - public $syncChunkSendTimer; + public $syncChunkSend; /** @var TimingsHandler */ - public $syncChunkSendPrepareTimer; + public $syncChunkSendPrepare; /** @var TimingsHandler */ - public $syncChunkLoadTimer; + public $syncChunkLoad; /** @var TimingsHandler */ - public $syncChunkLoadDataTimer; + public $syncChunkLoadData; /** @var TimingsHandler */ - public $syncChunkLoadEntitiesTimer; + public $syncChunkLoadEntities; /** @var TimingsHandler */ - public $syncChunkLoadTileEntitiesTimer; + public $syncChunkLoadTileEntities; /** @var TimingsHandler */ - public $syncChunkSaveTimer; + public $syncChunkSave; public function __construct(World $world){ $name = $world->getFolderName() . " - "; @@ -78,14 +78,14 @@ class WorldTimings{ $this->entityTick = new TimingsHandler(Timings::INCLUDED_BY_OTHER_TIMINGS_PREFIX . $name . "Tick Entities"); Timings::init(); //make sure the timers we want are available - $this->syncChunkSendTimer = new TimingsHandler("** " . $name . "Player Send Chunks", Timings::$playerChunkSendTimer); - $this->syncChunkSendPrepareTimer = new TimingsHandler("** " . $name . "Player Send Chunk Prepare", Timings::$playerChunkSendTimer); + $this->syncChunkSend = new TimingsHandler("** " . $name . "Player Send Chunks", Timings::$playerChunkSend); + $this->syncChunkSendPrepare = new TimingsHandler("** " . $name . "Player Send Chunk Prepare", Timings::$playerChunkSend); - $this->syncChunkLoadTimer = new TimingsHandler("** " . $name . "Chunk Load", Timings::$worldLoadTimer); - $this->syncChunkLoadDataTimer = new TimingsHandler("** " . $name . "Chunk Load - Data"); - $this->syncChunkLoadEntitiesTimer = new TimingsHandler("** " . $name . "Chunk Load - Entities"); - $this->syncChunkLoadTileEntitiesTimer = new TimingsHandler("** " . $name . "Chunk Load - TileEntities"); - $this->syncChunkSaveTimer = new TimingsHandler("** " . $name . "Chunk Save", Timings::$worldSaveTimer); + $this->syncChunkLoad = new TimingsHandler("** " . $name . "Chunk Load", Timings::$worldLoad); + $this->syncChunkLoadData = new TimingsHandler("** " . $name . "Chunk Load - Data"); + $this->syncChunkLoadEntities = new TimingsHandler("** " . $name . "Chunk Load - Entities"); + $this->syncChunkLoadTileEntities = new TimingsHandler("** " . $name . "Chunk Load - TileEntities"); + $this->syncChunkSave = new TimingsHandler("** " . $name . "Chunk Save", Timings::$worldSave); $this->doTick = new TimingsHandler($name . "World Tick"); }