13
0
geforkt von Mirrors/Paper

Migrate timings classes to new package

Dieser Commit ist enthalten in:
Zach Brown 2016-01-10 01:33:27 -06:00
Ursprung 1669598daa
Commit a4ab2f017d
2 geänderte Dateien mit 940 neuen und 940 gelöschten Zeilen

Datei-Diff unterdrückt, da er zu groß ist Diff laden

Datei anzeigen

@ -4,6 +4,197 @@ Date: Fri, 8 Jan 2016 23:36:39 -0600
Subject: [PATCH] Timings v2
diff --git a/src/main/java/co/aikar/timings/SpigotTimings.java b/src/main/java/co/aikar/timings/SpigotTimings.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/co/aikar/timings/SpigotTimings.java
@@ -0,0 +0,0 @@
+package co.aikar.timings;
+
+import net.minecraft.server.*;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import org.bukkit.craftbukkit.scheduler.CraftTask;
+
+public final class SpigotTimings {
+
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
+ public static final Timing tickablesTimer = Timings.ofSafe("Tickables");
+ public static final Timing schedulerTimer = Timings.ofSafe("Scheduler");
+ public static final Timing chunkIOTickTimer = Timings.ofSafe("ChunkIOTick");
+ public static final Timing timeUpdateTimer = Timings.ofSafe("Time Update");
+ public static final Timing serverCommandTimer = Timings.ofSafe("Server Command");
+ public static final Timing worldSaveTimer = Timings.ofSafe("World Save");
+
+ public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
+ public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
+
+ public static final Timing processQueueTimer = Timings.ofSafe("processQueue");
+
+ public static final Timing playerCommandTimer = Timings.ofSafe("playerCommand");
+
+ public static final Timing entityActivationCheckTimer = Timings.ofSafe("entityActivationCheck");
+ public static final Timing checkIfActiveTimer = Timings.ofSafe("checkIfActive");
+
+ public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
+ public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
+
+ private SpigotTimings() {}
+
+ /**
+ * Gets a timer associated with a plugins tasks.
+ * @param bukkitTask
+ * @param period
+ * @return
+ */
+ public static Timing getPluginTaskTimings(BukkitTask bukkitTask, long period) {
+ if (!bukkitTask.isSync()) {
+ return null;
+ }
+ Plugin plugin;
+
+ Runnable task = ((CraftTask) bukkitTask).task;
+
+ final Class<? extends Runnable> taskClass = task.getClass();
+ if (bukkitTask.getOwner() != null) {
+ plugin = bukkitTask.getOwner();
+ } else {
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
+ }
+
+ final String taskname;
+ if (taskClass.isAnonymousClass()) {
+ taskname = taskClass.getName();
+ } else {
+ taskname = taskClass.getCanonicalName();
+ }
+
+ String name = "Task: " +taskname;
+ if (period > 0) {
+ name += " (interval:" + period +")";
+ } else {
+ name += " (Single)";
+ }
+
+ if (plugin == null) {
+ return Timings.ofSafe(null, name, TimingsManager.PLUGIN_GROUP_HANDLER);
+ }
+
+ return Timings.ofSafe(plugin, name);
+ }
+
+ /**
+ * Get a named timer for the specified entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getEntityTimings(Entity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType, tickEntityTimer);
+ }
+
+ /**
+ * Get a named timer for the specified tile entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getTileEntityTimings(TileEntity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickTileEntity - " + entityType, tickTileEntityTimer);
+ }
+ public static Timing getCancelTasksTimer() {
+ return Timings.ofSafe("Cancel Tasks");
+ }
+ public static Timing getCancelTasksTimer(Plugin plugin) {
+ return Timings.ofSafe(plugin, "Cancel Tasks");
+ }
+
+ public static void stopServer() {
+ TimingsManager.stopServer();
+ }
+
+ public static Timing getBlockTiming(Block block) {
+ return Timings.ofSafe("## Scheduled Block: " + block.getName());
+ }
+}
diff --git a/src/main/java/co/aikar/timings/WorldTimingsHandler.java b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/co/aikar/timings/WorldTimingsHandler.java
@@ -0,0 +0,0 @@
+package co.aikar.timings;
+
+import net.minecraft.server.World;
+
+/**
+ * Set of timers per world, to track world specific timings.
+ */
+public class WorldTimingsHandler {
+ public final Timing mobSpawn;
+ public final Timing doChunkUnload;
+ public final Timing doPortalForcer;
+ public final Timing scheduledBlocks;
+ public final Timing scheduledBlocksCleanup;
+ public final Timing scheduledBlocksTicking;
+ public final Timing chunkTicks;
+ public final Timing chunkTicksBlocks;
+ public final Timing doVillages;
+ public final Timing doChunkMap;
+ public final Timing doChunkGC;
+ public final Timing doSounds;
+ public final Timing entityRemoval;
+ public final Timing entityTick;
+ public final Timing tileEntityTick;
+ public final Timing tileEntityPending;
+ public final Timing tracker;
+ public final Timing doTick;
+ public final Timing tickEntities;
+
+ public final Timing syncChunkLoadTimer;
+ public final Timing syncChunkLoadDataTimer;
+ public final Timing syncChunkLoadStructuresTimer;
+ public final Timing syncChunkLoadEntitiesTimer;
+ public final Timing syncChunkLoadTileEntitiesTimer;
+ public final Timing syncChunkLoadTileTicksTimer;
+ public final Timing syncChunkLoadPostTimer;
+
+ public WorldTimingsHandler(World server) {
+ String name = server.worldData.getName() +" - ";
+
+ mobSpawn = Timings.ofSafe(name + "mobSpawn");
+ doChunkUnload = Timings.ofSafe(name + "doChunkUnload");
+ scheduledBlocks = Timings.ofSafe(name + "Scheduled Blocks");
+ scheduledBlocksCleanup = Timings.ofSafe(name + "Scheduled Blocks - Cleanup");
+ scheduledBlocksTicking = Timings.ofSafe(name + "Scheduled Blocks - Ticking");
+ chunkTicks = Timings.ofSafe(name + "Chunk Ticks");
+ chunkTicksBlocks = Timings.ofSafe(name + "Chunk Ticks - Blocks");
+ doVillages = Timings.ofSafe(name + "doVillages");
+ doChunkMap = Timings.ofSafe(name + "doChunkMap");
+ doSounds = Timings.ofSafe(name + "doSounds");
+ doChunkGC = Timings.ofSafe(name + "doChunkGC");
+ doPortalForcer = Timings.ofSafe(name + "doPortalForcer");
+ entityTick = Timings.ofSafe(name + "entityTick");
+ entityRemoval = Timings.ofSafe(name + "entityRemoval");
+ tileEntityTick = Timings.ofSafe(name + "tileEntityTick");
+ tileEntityPending = Timings.ofSafe(name + "tileEntityPending");
+
+ syncChunkLoadTimer = Timings.ofSafe(name + "syncChunkLoad");
+ syncChunkLoadDataTimer = Timings.ofSafe(name + "syncChunkLoad - Data");
+ syncChunkLoadStructuresTimer = Timings.ofSafe(name + "chunkLoad - Structures");
+ syncChunkLoadEntitiesTimer = Timings.ofSafe(name + "chunkLoad - Entities");
+ syncChunkLoadTileEntitiesTimer = Timings.ofSafe(name + "chunkLoad - TileEntities");
+ syncChunkLoadTileTicksTimer = Timings.ofSafe(name + "chunkLoad - TileTicks");
+ syncChunkLoadPostTimer = Timings.ofSafe(name + "chunkLoad - Post");
+
+ tracker = Timings.ofSafe(name + "tracker");
+ doTick = Timings.ofSafe(name + "doTick");
+ tickEntities = Timings.ofSafe(name + "tickEntities");
+ }
+}
diff --git a/src/main/java/net/minecraft/server/Block.java b/src/main/java/net/minecraft/server/Block.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/Block.java
@ -13,10 +204,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected boolean z;
protected boolean isTileEntity;
+ // Spigot start
+ public org.spigotmc.timings.Timing timing;
+ public org.spigotmc.timings.Timing getTiming() {
+ public co.aikar.timings.Timing timing;
+ public co.aikar.timings.Timing getTiming() {
+ if (timing == null) {
+ timing = org.spigotmc.timings.SpigotTimings.getBlockTiming(this);
+ timing = co.aikar.timings.SpigotTimings.getBlockTiming(this);
+ }
+ return timing;
+ }
@ -34,7 +225,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.craftbukkit.LoggerOutputStream;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.craftbukkit.util.Waitable;
import org.bukkit.event.server.RemoteServerCommandEvent;
@ -47,8 +238,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.entity.Painting;
import org.bukkit.entity.Vehicle;
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import org.spigotmc.timings.Timing; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
+import co.aikar.timings.Timing; // Spigot
import org.bukkit.event.entity.EntityCombustByEntityEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.painting.PaintingBreakByEntityEvent;
@ -86,7 +277,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
public abstract class EntityLiving extends Entity {
@ -157,7 +348,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.craftbukkit.Main;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
// CraftBukkit end
public abstract class MinecraftServer implements Runnable, ICommandListener, IAsyncTaskHandler, IMojangStatistics {
@ -175,7 +366,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
protected void A() throws ExceptionWorldConflict { // CraftBukkit - added throws
- SpigotTimings.serverTickTimer.startTiming(); // Spigot
+ org.spigotmc.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Spigot
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.startTiming(); // Spigot
long i = System.nanoTime();
++this.ticks;
@ -185,7 +376,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
org.spigotmc.WatchdogThread.tick(); // Spigot
- SpigotTimings.serverTickTimer.stopTiming(); // Spigot
- org.spigotmc.CustomTimingsHandler.tick(); // Spigot
+ org.spigotmc.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Spigot
+ co.aikar.timings.TimingsManager.FULL_SERVER_TICK.stopTiming(); // Spigot
}
public void B() {
@ -197,7 +388,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.inventory.CraftingInventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.util.NumberConversions;
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
// CraftBukkit end
import org.github.paperspigot.PaperSpigotConfig; // PaperSpigot
@ -246,8 +437,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.apache.logging.log4j.Logger;
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import org.spigotmc.timings.Timing; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
+import co.aikar.timings.Timing; // Spigot
import org.bukkit.inventory.InventoryHolder; // CraftBukkit
public abstract class TileEntity {
@ -273,7 +464,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
import org.bukkit.generator.ChunkGenerator;
+import org.spigotmc.timings.SpigotTimings;
+import co.aikar.timings.SpigotTimings;
import java.util.*;
import java.util.concurrent.Callable;
@ -282,7 +473,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public final org.github.paperspigot.PaperSpigotWorldConfig paperSpigotConfig; // PaperSpigot
- public final SpigotTimings.WorldTimingsHandler timings; // Spigot
+ public final org.spigotmc.timings.WorldTimingsHandler timings; // Spigot
+ public final co.aikar.timings.WorldTimingsHandler timings; // Spigot
public CraftWorld getWorld() {
return this.world;
@ -291,7 +482,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
// CraftBukkit end
this.keepSpawnInMemory = this.paperSpigotConfig.keepSpawnInMemory; // PaperSpigot
- timings = new SpigotTimings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
+ timings = new org.spigotmc.timings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
+ timings = new co.aikar.timings.WorldTimingsHandler(this); // Spigot - code below can generate new world and access timings
this.entityLimiter = new org.spigotmc.TickLimiter(spigotConfig.entityMaxTickTime);
this.tileLimiter = new org.spigotmc.TickLimiter(spigotConfig.tileMaxTickTime);
}
@ -314,7 +505,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
timings.entityTick.startTiming(); // Spigot
guardEntityList = true; // Spigot
// CraftBukkit start - Use field for loop variable
+ org.spigotmc.timings.TimingHistory.entityTicks += this.entityList.size(); // Spigot
+ co.aikar.timings.TimingHistory.entityTicks += this.entityList.size(); // Spigot
int entitiesThisCycle = 0;
// PaperSpigot start - Disable tick limiters
//if (tickPosition < 0) tickPosition = 0;
@ -338,7 +529,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
timings.tileEntityPending.stopTiming(); // Spigot
+ org.spigotmc.timings.TimingHistory.tileEntityTicks += this.tileEntityList.size(); // Spigot
+ co.aikar.timings.TimingHistory.tileEntityTicks += this.tileEntityList.size(); // Spigot
+
this.methodProfiler.b();
this.methodProfiler.b();
@ -355,7 +546,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
entity.lastPitch = entity.pitch;
if (flag && entity.ad) {
++entity.ticksLived;
+ ++org.spigotmc.timings.TimingHistory.activatedEntityTicks; // Spigot
+ ++co.aikar.timings.TimingHistory.activatedEntityTicks; // Spigot
if (entity.vehicle != null) {
entity.ak();
} else {
@ -433,7 +624,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (this.areChunksLoadedBetween(nextticklistentry.a.a(-b0, -b0, -b0), nextticklistentry.a.a(b0, b0, b0))) {
IBlockData iblockdata = this.getType(nextticklistentry.a);
+ org.spigotmc.timings.Timing timing = iblockdata.getBlock().getTiming(); // Spigot
+ co.aikar.timings.Timing timing = iblockdata.getBlock().getTiming(); // Spigot
+ timing.startTiming(); // Spigot
if (iblockdata.getBlock().getMaterial() != Material.AIR && Block.a(iblockdata.getBlock(), nextticklistentry.a())) {
@ -459,7 +650,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
DefaultPermissions.registerCorePermissions();
CraftDefaultPermissions.registerCorePermissions();
helpMap.initializeCommands();
+ org.spigotmc.timings.Timings.reset(); // Spigot
+ co.aikar.timings.Timings.reset(); // Spigot
}
}
@ -701,7 +892,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
return false;
- }});
+ }}){{this.timings=org.spigotmc.timings.SpigotTimings.getCancelTasksTimer();}}; // Spigot
+ }}){{this.timings=co.aikar.timings.SpigotTimings.getCancelTasksTimer();}}; // Spigot
handle(task, 0l);
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
@ -710,7 +901,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
- });
+ }){{this.timings=org.spigotmc.timings.SpigotTimings.getCancelTasksTimer(plugin);}}; // Spigot
+ }){{this.timings=co.aikar.timings.SpigotTimings.getCancelTasksTimer(plugin);}}; // Spigot
handle(task, 0l);
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
@ -719,7 +910,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
CraftScheduler.this.temp.clear();
}
- });
+ }){{this.timings=org.spigotmc.timings.SpigotTimings.getCancelTasksTimer();}}; // Spigot
+ }){{this.timings=co.aikar.timings.SpigotTimings.getCancelTasksTimer();}}; // Spigot
handle(task, 0l);
for (CraftTask taskPending = head.getNext(); taskPending != null; taskPending = taskPending.getNext()) {
if (taskPending == task) {
@ -743,8 +934,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.Bukkit;
-import org.bukkit.craftbukkit.SpigotTimings; // Spigot
-import org.spigotmc.CustomTimingsHandler; // Spigot
+import org.spigotmc.timings.SpigotTimings; // Spigot
+import org.spigotmc.timings.Timing; // Spigot
+import co.aikar.timings.SpigotTimings; // Spigot
+import co.aikar.timings.Timing; // Spigot
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitTask;
@ -835,7 +1026,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.server.World;
-import org.bukkit.craftbukkit.SpigotTimings;
-import org.bukkit.entity.Creeper;
+import org.spigotmc.timings.SpigotTimings;
+import co.aikar.timings.SpigotTimings;
+
public class ActivationRange
@ -848,7 +1039,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import net.minecraft.server.Blocks;
import net.minecraft.server.World;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.spigotmc.timings.SpigotTimings;
+import co.aikar.timings.SpigotTimings;
// PaperSpigot start
import java.util.HashSet;
@ -905,8 +1096,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
+import org.spigotmc.timings.Timings;
+import org.spigotmc.timings.TimingsManager;
+import co.aikar.timings.Timings;
+import co.aikar.timings.TimingsManager;
public class SpigotConfig
{
@ -950,195 +1141,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static void nettyThreads()
{
int count = getInt( "settings.netty-threads", 4 );
diff --git a/src/main/java/org/spigotmc/timings/SpigotTimings.java b/src/main/java/org/spigotmc/timings/SpigotTimings.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/org/spigotmc/timings/SpigotTimings.java
@@ -0,0 +0,0 @@
+package org.spigotmc.timings;
+
+import net.minecraft.server.*;
+import org.bukkit.plugin.Plugin;
+import org.bukkit.scheduler.BukkitTask;
+
+import org.bukkit.craftbukkit.scheduler.CraftTask;
+
+public final class SpigotTimings {
+
+ public static final Timing playerListTimer = Timings.ofSafe("Player List");
+ public static final Timing connectionTimer = Timings.ofSafe("Connection Handler");
+ public static final Timing tickablesTimer = Timings.ofSafe("Tickables");
+ public static final Timing schedulerTimer = Timings.ofSafe("Scheduler");
+ public static final Timing chunkIOTickTimer = Timings.ofSafe("ChunkIOTick");
+ public static final Timing timeUpdateTimer = Timings.ofSafe("Time Update");
+ public static final Timing serverCommandTimer = Timings.ofSafe("Server Command");
+ public static final Timing worldSaveTimer = Timings.ofSafe("World Save");
+
+ public static final Timing tickEntityTimer = Timings.ofSafe("## tickEntity");
+ public static final Timing tickTileEntityTimer = Timings.ofSafe("## tickTileEntity");
+
+ public static final Timing processQueueTimer = Timings.ofSafe("processQueue");
+
+ public static final Timing playerCommandTimer = Timings.ofSafe("playerCommand");
+
+ public static final Timing entityActivationCheckTimer = Timings.ofSafe("entityActivationCheck");
+ public static final Timing checkIfActiveTimer = Timings.ofSafe("checkIfActive");
+
+ public static final Timing antiXrayUpdateTimer = Timings.ofSafe("anti-xray - update");
+ public static final Timing antiXrayObfuscateTimer = Timings.ofSafe("anti-xray - obfuscate");
+
+ private SpigotTimings() {}
+
+ /**
+ * Gets a timer associated with a plugins tasks.
+ * @param bukkitTask
+ * @param period
+ * @return
+ */
+ public static Timing getPluginTaskTimings(BukkitTask bukkitTask, long period) {
+ if (!bukkitTask.isSync()) {
+ return null;
+ }
+ Plugin plugin;
+
+ Runnable task = ((CraftTask) bukkitTask).task;
+
+ final Class<? extends Runnable> taskClass = task.getClass();
+ if (bukkitTask.getOwner() != null) {
+ plugin = bukkitTask.getOwner();
+ } else {
+ plugin = TimingsManager.getPluginByClassloader(taskClass);
+ }
+
+ final String taskname;
+ if (taskClass.isAnonymousClass()) {
+ taskname = taskClass.getName();
+ } else {
+ taskname = taskClass.getCanonicalName();
+ }
+
+ String name = "Task: " +taskname;
+ if (period > 0) {
+ name += " (interval:" + period +")";
+ } else {
+ name += " (Single)";
+ }
+
+ if (plugin == null) {
+ return Timings.ofSafe(null, name, TimingsManager.PLUGIN_GROUP_HANDLER);
+ }
+
+ return Timings.ofSafe(plugin, name);
+ }
+
+ /**
+ * Get a named timer for the specified entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getEntityTimings(Entity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickEntity - " + entityType, tickEntityTimer);
+ }
+
+ /**
+ * Get a named timer for the specified tile entity type to track type specific timings.
+ * @param entity
+ * @return
+ */
+ public static Timing getTileEntityTimings(TileEntity entity) {
+ String entityType = entity.getClass().getName();
+ return Timings.ofSafe("Minecraft", "## tickTileEntity - " + entityType, tickTileEntityTimer);
+ }
+ public static Timing getCancelTasksTimer() {
+ return Timings.ofSafe("Cancel Tasks");
+ }
+ public static Timing getCancelTasksTimer(Plugin plugin) {
+ return Timings.ofSafe(plugin, "Cancel Tasks");
+ }
+
+ public static void stopServer() {
+ TimingsManager.stopServer();
+ }
+
+ public static Timing getBlockTiming(Block block) {
+ return Timings.ofSafe("## Scheduled Block: " + block.getName());
+ }
+}
diff --git a/src/main/java/org/spigotmc/timings/WorldTimingsHandler.java b/src/main/java/org/spigotmc/timings/WorldTimingsHandler.java
new file mode 100644
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
--- /dev/null
+++ b/src/main/java/org/spigotmc/timings/WorldTimingsHandler.java
@@ -0,0 +0,0 @@
+package org.spigotmc.timings;
+
+import net.minecraft.server.World;
+
+/**
+ * Set of timers per world, to track world specific timings.
+ */
+public class WorldTimingsHandler {
+ public final Timing mobSpawn;
+ public final Timing doChunkUnload;
+ public final Timing doPortalForcer;
+ public final Timing scheduledBlocks;
+ public final Timing scheduledBlocksCleanup;
+ public final Timing scheduledBlocksTicking;
+ public final Timing chunkTicks;
+ public final Timing chunkTicksBlocks;
+ public final Timing doVillages;
+ public final Timing doChunkMap;
+ public final Timing doChunkGC;
+ public final Timing doSounds;
+ public final Timing entityRemoval;
+ public final Timing entityTick;
+ public final Timing tileEntityTick;
+ public final Timing tileEntityPending;
+ public final Timing tracker;
+ public final Timing doTick;
+ public final Timing tickEntities;
+
+ public final Timing syncChunkLoadTimer;
+ public final Timing syncChunkLoadDataTimer;
+ public final Timing syncChunkLoadStructuresTimer;
+ public final Timing syncChunkLoadEntitiesTimer;
+ public final Timing syncChunkLoadTileEntitiesTimer;
+ public final Timing syncChunkLoadTileTicksTimer;
+ public final Timing syncChunkLoadPostTimer;
+
+ public WorldTimingsHandler(World server) {
+ String name = server.worldData.getName() +" - ";
+
+ mobSpawn = Timings.ofSafe(name + "mobSpawn");
+ doChunkUnload = Timings.ofSafe(name + "doChunkUnload");
+ scheduledBlocks = Timings.ofSafe(name + "Scheduled Blocks");
+ scheduledBlocksCleanup = Timings.ofSafe(name + "Scheduled Blocks - Cleanup");
+ scheduledBlocksTicking = Timings.ofSafe(name + "Scheduled Blocks - Ticking");
+ chunkTicks = Timings.ofSafe(name + "Chunk Ticks");
+ chunkTicksBlocks = Timings.ofSafe(name + "Chunk Ticks - Blocks");
+ doVillages = Timings.ofSafe(name + "doVillages");
+ doChunkMap = Timings.ofSafe(name + "doChunkMap");
+ doSounds = Timings.ofSafe(name + "doSounds");
+ doChunkGC = Timings.ofSafe(name + "doChunkGC");
+ doPortalForcer = Timings.ofSafe(name + "doPortalForcer");
+ entityTick = Timings.ofSafe(name + "entityTick");
+ entityRemoval = Timings.ofSafe(name + "entityRemoval");
+ tileEntityTick = Timings.ofSafe(name + "tileEntityTick");
+ tileEntityPending = Timings.ofSafe(name + "tileEntityPending");
+
+ syncChunkLoadTimer = Timings.ofSafe(name + "syncChunkLoad");
+ syncChunkLoadDataTimer = Timings.ofSafe(name + "syncChunkLoad - Data");
+ syncChunkLoadStructuresTimer = Timings.ofSafe(name + "chunkLoad - Structures");
+ syncChunkLoadEntitiesTimer = Timings.ofSafe(name + "chunkLoad - Entities");
+ syncChunkLoadTileEntitiesTimer = Timings.ofSafe(name + "chunkLoad - TileEntities");
+ syncChunkLoadTileTicksTimer = Timings.ofSafe(name + "chunkLoad - TileTicks");
+ syncChunkLoadPostTimer = Timings.ofSafe(name + "chunkLoad - Post");
+
+ tracker = Timings.ofSafe(name + "tracker");
+ doTick = Timings.ofSafe(name + "doTick");
+ tickEntities = Timings.ofSafe(name + "tickEntities");
+ }
+}
--