Yatopia/patches/server/0014-Purpur-Add-more-timings-timers.patch
2020-07-17 18:05:50 +02:00

212 lines
12 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: tr7zw <tr7zw@live.de>
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 2966c5731761b125d841c8f3ea80f68bc189c162..ae55867370e496043994867b31c82c37b690efc2 100644
--- a/src/main/java/co/aikar/timings/MinecraftTimings.java
+++ b/src/main/java/co/aikar/timings/MinecraftTimings.java
@@ -45,6 +45,28 @@ public final class MinecraftTimings {
public static final Timing scoreboardScoreSearch = Timings.ofSafe("Scoreboard score search"); // Tuinity - add timings for scoreboard search
+ // 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<Class<?>, 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 26bbf2fc413e193507272d930e42e1ec9133abd7..9c14854a971a8818b7fe4acca7113c1e09ad32f0 100644
--- a/src/main/java/net/minecraft/server/EntityLiving.java
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
@@ -2467,7 +2467,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);
@@ -2736,18 +2740,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;
@@ -2773,21 +2782,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<PathfinderGoalWrapped> 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<PathfinderGoalWrapped> 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<PathfinderGoalWrapped> 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<PathfinderGoalWrapped> 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 d1dbb3cb4060819e1fb82d700cb7a909ba6c500b..7f64c327b8a55d33fdbaa0dec62c14a3d7962ad7 100644
--- a/src/main/java/net/minecraft/server/WorldServer.java
+++ b/src/main/java/net/minecraft/server/WorldServer.java
@@ -1325,7 +1325,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();
}