mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-22 19:06:35 +00:00
Add specialized entityBaseTick timer for item entities
since item merging is a potential hotspot, we want to know if this code section is a performance problem. Current timers only tell us whether overall ticking of a particular entity is slow, but that includes movement and therefore isn't particularly helpful.
This commit is contained in:
parent
7bc5d8c824
commit
054c06fab9
@ -41,6 +41,7 @@ use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
||||
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\timings\Timings;
|
||||
use function max;
|
||||
|
||||
class ItemEntity extends Entity{
|
||||
@ -113,6 +114,9 @@ class ItemEntity extends Entity{
|
||||
return false;
|
||||
}
|
||||
|
||||
Timings::$itemEntityBaseTick->startTiming();
|
||||
try{
|
||||
|
||||
$hasUpdate = parent::entityBaseTick($tickDiff);
|
||||
|
||||
if($this->isFlaggedForDespawn()){
|
||||
@ -164,6 +168,9 @@ class ItemEntity extends Entity{
|
||||
}
|
||||
|
||||
return $hasUpdate;
|
||||
}finally{
|
||||
Timings::$itemEntityBaseTick->stopTiming();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -107,6 +107,8 @@ abstract class Timings{
|
||||
/** @var TimingsHandler */
|
||||
public static $livingEntityBaseTick;
|
||||
|
||||
public static TimingsHandler $itemEntityBaseTick;
|
||||
|
||||
/** @var TimingsHandler */
|
||||
public static $schedulerSync;
|
||||
/** @var TimingsHandler */
|
||||
@ -200,6 +202,7 @@ abstract class Timings{
|
||||
|
||||
self::$entityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Entity Base Tick");
|
||||
self::$livingEntityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Entity Base Tick - Living");
|
||||
self::$itemEntityBaseTick = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Entity Base Tick - ItemEntity");
|
||||
|
||||
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");
|
||||
|
Loading…
x
Reference in New Issue
Block a user