Timings: added new timers for entity move collision checks and projectile move ray tracing

projectiles get their own distinct sub-timer, since the logic is completely different from regular entities.
This commit is contained in:
Dylan K. Taylor 2023-03-19 15:49:35 +00:00
parent eec53f9ae0
commit 607bdfa42f
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D
3 changed files with 18 additions and 2 deletions

View File

@ -1139,6 +1139,7 @@ abstract class Entity{
$this->blocksAround = null;
Timings::$entityMove->startTiming();
Timings::$entityMoveCollision->startTiming();
$wantedX = $dx;
$wantedY = $dy;
@ -1223,6 +1224,7 @@ abstract class Entity{
$this->boundingBox = $moveBB;
}
Timings::$entityMoveCollision->stopTiming();
$this->location = new Location(
($this->boundingBox->minX + $this->boundingBox->maxX) / 2,

View File

@ -175,7 +175,8 @@ abstract class Projectile extends Entity{
protected function move(float $dx, float $dy, float $dz) : void{
$this->blocksAround = null;
Timings::$entityMove->startTiming();
Timings::$projectileMove->startTiming();
Timings::$projectileMoveRayTrace->startTiming();
$start = $this->location->asVector3();
$end = $start->add($dx, $dy, $dz);
@ -221,6 +222,8 @@ abstract class Projectile extends Entity{
}
}
Timings::$projectileMoveRayTrace->stopTiming();
$this->location = Location::fromObject(
$end,
$this->location->world,
@ -268,7 +271,7 @@ abstract class Projectile extends Entity{
$this->getWorld()->onEntityMoved($this);
$this->checkBlockIntersections();
Timings::$entityMove->stopTiming();
Timings::$projectileMove->stopTiming();
}
/**

View File

@ -89,6 +89,12 @@ abstract class Timings{
/** @var TimingsHandler */
public static $entityMove;
public static TimingsHandler $entityMoveCollision;
public static TimingsHandler $projectileMove;
public static TimingsHandler $projectileMoveRayTrace;
/** @var TimingsHandler */
public static $playerCheckNearEntities;
/** @var TimingsHandler */
@ -183,6 +189,11 @@ abstract class Timings{
self::$syncPlayerDataSave = new TimingsHandler("Player Data Save");
self::$entityMove = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Entity Movement");
self::$entityMoveCollision = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Entity Movement - Collision Checks", self::$entityMove);
self::$projectileMove = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Projectile Movement", self::$entityMove);
self::$projectileMoveRayTrace = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Projectile Movement - Ray Tracing", self::$projectileMove);
self::$playerCheckNearEntities = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "checkNearEntities");
self::$tickEntity = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Entity Tick");
self::$tickTileEntity = new TimingsHandler(self::INCLUDED_BY_OTHER_TIMINGS_PREFIX . "Block Entity Tick");