From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: tr7zw Date: Tue, 21 Apr 2020 15:49:52 +0200 Subject: [PATCH] Purpur Add more timings timers diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java index 85b25eace786fa0d7694afa405f9d2bdf4937b6e..b81eeea483e1313a3b4a329bf09ac6e40a7b267f 100644 --- a/src/main/java/co/aikar/timings/MinecraftTimings.java +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java @@ -46,6 +46,28 @@ public final class MinecraftTimings { public static final Timing scoreboardScoreSearch = Timings.ofSafe("Scoreboard score search"); // Tuinity - add timings for scoreboard search public static final Timing distanceManagerTick = Timings.ofSafe("Distance Manager Tick"); // Tuinity - add timings for distance manager + // Purpur start + public static final Timing goalCleanup = Timings.ofSafe("PathfinderGoal - Cleanup"); + public static final Timing goalUpdate = Timings.ofSafe("PathfinderGoal - Update"); + public static final Timing goalTick = Timings.ofSafe("PathfinderGoal - Tick"); + + public static final Timing entityMovementTick = Timings.ofSafe("Entity Movement"); + public static final Timing entityMovementTickAI = Timings.ofSafe("Entity Movement - AI"); + public static final Timing entityMovementTickNewAI = Timings.ofSafe("Entity Movement - New AI"); + public static final Timing entityMovementTickJump = Timings.ofSafe("Entity Movement - Jump"); + public static final Timing entityMovementTickTravel = Timings.ofSafe("Entity Movement - Travel"); + public static final Timing entityMovementTickPush = Timings.ofSafe("Entity Movement - Push"); + + public static final Timing entityInsentientSensing = Timings.ofSafe("Entity Insentient - Sensing"); + public static final Timing entityInsentientTargetSelector = Timings.ofSafe("Entity Insentient - TargetSelector"); + public static final Timing entityInsentientGoalSelector = Timings.ofSafe("Entity Insentient - GoalSelector"); + public static final Timing entityInsentientNavigation = Timings.ofSafe("Entity Insentient - Navigation"); + public static final Timing entityInsentientMobTick = Timings.ofSafe("Entity Insentient - MobTick"); + public static final Timing entityInsentientControls = Timings.ofSafe("Entity Insentient - Controls"); + + public static final Timing passengerTick = Timings.ofSafe("Passenger Tick"); + // Purpur end + private static final Map, String> taskNameCache = new MapMaker().weakKeys().makeMap(); private MinecraftTimings() {} diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java index 605bbf0174e60f795e445193a0284739ea452946..9a937623aaf59d3159038f06c1ede1a1d9bc1916 100644 --- a/src/main/java/net/minecraft/server/EntityInsentient.java +++ b/src/main/java/net/minecraft/server/EntityInsentient.java @@ -748,21 +748,32 @@ public abstract class EntityInsentient extends EntityLiving { } // Paper end this.world.getMethodProfiler().enter("sensing"); + co.aikar.timings.MinecraftTimings.entityInsentientSensing.startTiming(); // Purpur this.bv.a(); + co.aikar.timings.MinecraftTimings.entityInsentientSensing.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("targetSelector"); + co.aikar.timings.MinecraftTimings.entityInsentientTargetSelector.startTiming(); // Purpur this.targetSelector.doTick(); + co.aikar.timings.MinecraftTimings.entityInsentientTargetSelector.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("goalSelector"); + co.aikar.timings.MinecraftTimings.entityInsentientGoalSelector.startTiming(); // Purpur this.goalSelector.doTick(); + co.aikar.timings.MinecraftTimings.entityInsentientGoalSelector.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("navigation"); + co.aikar.timings.MinecraftTimings.entityInsentientNavigation.startTiming(); // Purpur this.navigation.c(); + co.aikar.timings.MinecraftTimings.entityInsentientNavigation.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("mob tick"); + co.aikar.timings.MinecraftTimings.entityInsentientMobTick.startTiming(); // Purpur this.mobTick(); + co.aikar.timings.MinecraftTimings.entityInsentientMobTick.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("controls"); + co.aikar.timings.MinecraftTimings.entityInsentientControls.startTiming(); // Purpur this.world.getMethodProfiler().enter("move"); this.moveController.a(); this.world.getMethodProfiler().exitEnter("look"); @@ -770,6 +781,7 @@ public abstract class EntityInsentient extends EntityLiving { this.world.getMethodProfiler().exitEnter("jump"); this.bp.b(); this.world.getMethodProfiler().exit(); + co.aikar.timings.MinecraftTimings.entityInsentientControls.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.M(); } diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java index 0170b2e877d4ef0b24a9c1e48da061e02cda2653..a1819225ea0c3ceb677877586c7b9176ffd36a4d 100644 --- a/src/main/java/net/minecraft/server/EntityLiving.java +++ b/src/main/java/net/minecraft/server/EntityLiving.java @@ -2464,7 +2464,11 @@ public abstract class EntityLiving extends Entity { } } - this.movementTick(); + + MinecraftTimings.entityMovementTick.startTiming(); // Purpur + if (!dead) this.movementTick(); // Purpur + MinecraftTimings.entityMovementTick.stopTiming(); // Purpur + double d0 = this.locX() - this.lastX; double d1 = this.locZ() - this.lastZ; float f = (float) (d0 * d0 + d1 * d1); @@ -2733,18 +2737,23 @@ public abstract class EntityLiving extends Entity { this.setMot(d4, d5, d6); this.world.getMethodProfiler().enter("ai"); + co.aikar.timings.MinecraftTimings.entityMovementTickAI.startTiming(); // Purpur if (this.isFrozen()) { this.jumping = false; this.aY = 0.0F; this.ba = 0.0F; } else if (this.doAITick()) { this.world.getMethodProfiler().enter("newAi"); + co.aikar.timings.MinecraftTimings.entityMovementTickNewAI.startTiming(); // Purpur this.doTick(); + co.aikar.timings.MinecraftTimings.entityMovementTickNewAI.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); } + co.aikar.timings.MinecraftTimings.entityMovementTickAI.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("jump"); + co.aikar.timings.MinecraftTimings.entityMovementTickJump.startTiming(); // Purpur if (this.jumping && this.cS()) { double d7; @@ -2770,21 +2779,26 @@ public abstract class EntityLiving extends Entity { } else { this.jumpTicks = 0; } + co.aikar.timings.MinecraftTimings.entityMovementTickJump.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("travel"); - this.aY *= 0.98F; - this.ba *= 0.98F; + co.aikar.timings.MinecraftTimings.entityMovementTickTravel.startTiming(); // Purpur + this.aZ *= 0.98F; + this.bb *= 0.98F; this.t(); AxisAlignedBB axisalignedbb = this.getBoundingBox(); this.f(new Vec3D((double) this.aY, (double) this.aZ, (double) this.ba)); + co.aikar.timings.MinecraftTimings.entityMovementTickTravel.stopTiming(); // Purpur this.world.getMethodProfiler().exit(); this.world.getMethodProfiler().enter("push"); + co.aikar.timings.MinecraftTimings.entityMovementTickPush.startTiming(); // Purpur if (this.bm > 0) { --this.bm; this.a(axisalignedbb, this.getBoundingBox()); } + co.aikar.timings.MinecraftTimings.entityMovementTickPush.stopTiming(); // Purpur this.collideNearby(); this.world.getMethodProfiler().exit(); diff --git a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java index d3f0327a2a7cdedf3fe8d10df981a9f1cb378d26..cce7cac92b3256576fb35d5d03719b15826f6ebc 100644 --- a/src/main/java/net/minecraft/server/PathfinderGoalSelector.java +++ b/src/main/java/net/minecraft/server/PathfinderGoalSelector.java @@ -80,7 +80,7 @@ public class PathfinderGoalSelector { public void doTick() { GameProfilerFiller gameprofilerfiller = (GameProfilerFiller) this.e.get(); - + co.aikar.timings.MinecraftTimings.goalCleanup.startTiming(); gameprofilerfiller.enter("goalCleanup"); // Paper start - remove streams from pathfindergoalselector for (Iterator iterator = this.d.iterator(); iterator.hasNext();) { @@ -100,8 +100,10 @@ public class PathfinderGoalSelector { } }); + co.aikar.timings.MinecraftTimings.goalCleanup.stopTiming(); gameprofilerfiller.exit(); gameprofilerfiller.enter("goalUpdate"); + co.aikar.timings.MinecraftTimings.goalUpdate.startTiming(); // Paper start - remove streams from pathfindergoalselector goal_update_loop: for (Iterator iterator = this.d.iterator(); iterator.hasNext();) { PathfinderGoalWrapped wrappedGoal = iterator.next(); @@ -144,8 +146,10 @@ public class PathfinderGoalSelector { wrappedGoal.c(); } // Paper end - remove streams from pathfindergoalselector + co.aikar.timings.MinecraftTimings.goalUpdate.stopTiming(); gameprofilerfiller.exit(); gameprofilerfiller.enter("goalTick"); + co.aikar.timings.MinecraftTimings.goalTick.startTiming(); // Paper start - remove streams from pathfindergoalselector for (Iterator iterator = this.d.iterator(); iterator.hasNext();) { PathfinderGoalWrapped wrappedGoal = iterator.next(); @@ -155,6 +159,7 @@ public class PathfinderGoalSelector { } // Paper end - remove streams from pathfindergoalselector gameprofilerfiller.exit(); + co.aikar.timings.MinecraftTimings.goalTick.stopTiming(); } public final Stream getExecutingGoals() { return d(); } // Paper - OBFHELPER diff --git a/src/main/java/net/minecraft/server/WorldServer.java b/src/main/java/net/minecraft/server/WorldServer.java index 8388629f573ff8ac4aea0b8fe6b041e293f70a2d..90b159db4e36d67e742dcfc92dbb56af7f9f9acb 100644 --- a/src/main/java/net/minecraft/server/WorldServer.java +++ b/src/main/java/net/minecraft/server/WorldServer.java @@ -1337,7 +1337,9 @@ public class WorldServer extends World implements GeneratorAccessSeed { return IRegistry.ENTITY_TYPE.getKey(entity1.getEntityType()).toString(); }); gameprofilerfiller.c("tickPassenger"); + co.aikar.timings.MinecraftTimings.passengerTick.startTiming(); // Purpur entity1.passengerTick(); + co.aikar.timings.MinecraftTimings.passengerTick.stopTiming(); // Purpur gameprofilerfiller.exit(); }