Re-enable the vanilla debug MethodProfiler and /debug command

This is highly useful for profiling vanilla code, and in some cases plugin code.  It is somewhat expensive, though, which is why it was initially disabled.

I chose to use a system property instead of a configuration setting because 1) the MethodProfiler is exclusive to CraftBukkit and not part of the general API (the timings system is the general API equivalent), and 2) using a static final boolean property _may_ allow the JITter to optimize out the methods when disabled (though I'm not sure of it).

There are several changes to fix cases where the profiler code was broken slightly by other craftbukkit changes.  All of cases have been fixed, except for the block entity ticking one, due to the cost of the getSimpleName call.  For that, a ticking entry is used instead, so that time spent actually ticking the block entities can be compared with time processing the list.

This (effectively) reverts 7dde6cc566.

By: Pokechu22 <Pokechu022@gmail.com>
This commit is contained in:
CraftBukkit/Spigot
2017-01-18 17:42:35 -08:00
parent 03cf4ffdf1
commit 49376274b6
6 changed files with 121 additions and 159 deletions

View File

@@ -478,7 +478,7 @@
}
}
@@ -1867,19 +2161,67 @@
@@ -1867,19 +2161,70 @@
if (!this.world.isClientSide && !this.dead) {
this.world.methodProfiler.a("changeDimension");
MinecraftServer minecraftserver = this.B_();
@@ -522,7 +522,10 @@
+ return null;
+ }
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
+ return this.teleportTo(exit, true);
+ // Need to make sure the profiler state is reset afterwards (but we still want to time the call)
+ Entity entity = this.teleportTo(exit, true);
+ this.world.methodProfiler.b();
+ return entity;
+ }
+ return null;
+ }
@@ -549,7 +552,7 @@
BlockPosition blockposition;
if (i == 1) {
@@ -1908,12 +2250,18 @@
@@ -1908,12 +2253,18 @@
blockposition = new BlockPosition(this);
}
@@ -569,7 +572,7 @@
if (j == 1 && i == 1) {
BlockPosition blockposition1 = worldserver1.q(worldserver1.getSpawn());
@@ -1921,6 +2269,7 @@
@@ -1921,6 +2272,7 @@
} else {
entity.setPositionRotation(blockposition, entity.yaw, entity.pitch);
}
@@ -577,7 +580,7 @@
boolean flag = entity.attachedToPlayer;
@@ -1928,6 +2277,14 @@
@@ -1928,13 +2280,21 @@
worldserver1.addEntity(entity);
entity.attachedToPlayer = flag;
worldserver1.entityJoinedWorld(entity, false);
@@ -592,7 +595,15 @@
}
this.dead = true;
@@ -2038,6 +2395,11 @@
this.world.methodProfiler.b();
worldserver.m();
worldserver1.m();
- this.world.methodProfiler.b();
+ // this.world.methodProfiler.b(); // CraftBukkit: Moved up to keep balanced
return entity;
} else {
return null;
@@ -2038,6 +2398,11 @@
}
public void setCustomName(String s) {
@@ -604,7 +615,7 @@
this.datawatcher.set(Entity.aA, s);
}
@@ -2095,7 +2457,26 @@
@@ -2095,7 +2460,26 @@
}
public void a(AxisAlignedBB axisalignedbb) {
@@ -632,7 +643,7 @@
}
public float getHeadHeight() {
@@ -2269,7 +2650,7 @@
@@ -2269,7 +2653,7 @@
for (Iterator iterator = this.bx().iterator(); iterator.hasNext(); entity.a(oclass, set)) {
entity = (Entity) iterator.next();
if (oclass.isAssignableFrom(entity.getClass())) {