org.spigotmc.CustomTimingsHandler Java Examples

The following examples show how to use org.spigotmc.CustomTimingsHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpigotTimingsCommand.java    From LagMonitor with MIT License 6 votes vote down vote up
@Override
protected void sendTimings(CommandSender sender) {
    //place sampleTime here to be very accurate
    long sampleTime = System.nanoTime() - TimingsCommand.timingStart;
    if (TimeUnit.NANOSECONDS.toMinutes(sampleTime) <= 5) {
        sendError(sender, "Sampling time is too low");
        return;
    }

    Queue<CustomTimingsHandler> handlers = Reflection.getField(CustomTimingsHandler.class, "HANDLERS", Queue.class)
            .get(null);

    List<BaseComponent[]> lines = new ArrayList<>();
    sendParsedOutput(handlers, lines, sampleTime);

    Pages pagination = new Pages("Paper Timings", lines);
    pagination.send(sender);

    this.plugin.getPageManager().setPagination(sender.getName(), pagination);
}
 
Example #2
Source File: SpigotTimingsCommand.java    From LagMonitor with MIT License 6 votes vote down vote up
@Override
protected void sendTimings(CommandSender sender) {
    //place sampleTime here to be very accurate
    long sampleTime = System.nanoTime() - TimingsCommand.timingStart;
    if (TimeUnit.NANOSECONDS.toMinutes(sampleTime) <= 5) {
        sendError(sender, "Sampling time is too low");
        return;
    }

    Queue<CustomTimingsHandler> handlers = Reflection.getField(CustomTimingsHandler.class, "HANDLERS", Queue.class)
            .get(null);

    List<BaseComponent[]> lines = new ArrayList<>();
    sendParsedOutput(handlers, lines, sampleTime);

    Pages pagination = new Pages("Paper Timings", lines);
    pagination.send(sender);

    this.plugin.getPageManager().setPagination(sender.getName(), pagination);
}
 
Example #3
Source File: TimingsHelper.java    From MapManager with MIT License 5 votes vote down vote up
private static Object createHandler(String name) {
	if (!PAPER_SPIGOT) {
		return new CustomTimingsHandler(name);
	} else {
		try {
			Class<?> clazz = Class.forName("co.aikar.timings.Timings");
			return clazz.getDeclaredMethod("of", Plugin.class, String.class).invoke(null, MapManagerPlugin.instance, name);
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
	}
}
 
Example #4
Source File: SpigotTimings.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
public WorldTimingsHandler(World server) {
    String name = server.worldInfo.getWorldName() +" - ";

    mobSpawn = new CustomTimingsHandler("** " + name + "mobSpawn");
    doChunkUnload = new CustomTimingsHandler("** " + name + "doChunkUnload");
    doTickPending = new CustomTimingsHandler("** " + name + "doTickPending");
    doTickTiles = new CustomTimingsHandler("** " + name + "doTickTiles");
    doVillages = new CustomTimingsHandler("** " + name + "doVillages");
    doChunkMap = new CustomTimingsHandler("** " + name + "doChunkMap");
    doSounds = new CustomTimingsHandler("** " + name + "doSounds");
    doChunkGC = new CustomTimingsHandler("** " + name + "doChunkGC");
    doPortalForcer = new CustomTimingsHandler("** " + name + "doPortalForcer");
    entityTick = new CustomTimingsHandler("** " + name + "entityTick");
    tileEntityTick = new CustomTimingsHandler("** " + name + "tileEntityTick");
    tileEntityPending = new CustomTimingsHandler("** " + name + "tileEntityPending");

    syncChunkLoadTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad");
    syncChunkLoadDataTimer = new CustomTimingsHandler("** " + name + "syncChunkLoad - Data");
    syncChunkLoadStructuresTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Structures");
    syncChunkLoadEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Entities");
    syncChunkLoadTileEntitiesTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileEntities");
    syncChunkLoadTileTicksTimer = new CustomTimingsHandler("** " + name + "chunkLoad - TileTicks");
    syncChunkLoadPostTimer = new CustomTimingsHandler("** " + name + "chunkLoad - Post");


    tracker = new CustomTimingsHandler(name + "tracker");
    doTick = new CustomTimingsHandler(name + "doTick");
    tickEntities = new CustomTimingsHandler(name + "tickEntities");
}
 
Example #5
Source File: TimingsCommand.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public void executeSpigotTimings(CommandSender sender, String[] args) {
    if ("on".equals(args[0])) {
        ((SimplePluginManager) Bukkit.getPluginManager()).useTimings(true);
        CustomTimingsHandler.reload();
        sender.sendMessage("Enabled Timings & Reset");
        return;
    } else if ("off".equals(args[0])) {
        ((SimplePluginManager) Bukkit.getPluginManager()).useTimings(false);
        sender.sendMessage("Disabled Timings");
        return;
    }

    if (!Bukkit.getPluginManager().useTimings()) {
        sender.sendMessage("Please enable timings by typing /timings on");
        return;
    }

    boolean paste = "paste".equals(args[0]);
    if ("reset".equals(args[0])) {
        CustomTimingsHandler.reload();
        sender.sendMessage("Timings reset");
    } else if ("merged".equals(args[0]) || "report".equals(args[0]) || paste) {
        long sampleTime = System.nanoTime() - timingStart;
        int index = 0;
        File timingFolder = new File("timings");
        timingFolder.mkdirs();
        File timings = new File(timingFolder, "timings.txt");
        ByteArrayOutputStream bout = (paste) ? new ByteArrayOutputStream() : null;
        while (timings.exists()) timings = new File(timingFolder, "timings" + (++index) + ".txt");
        PrintStream fileTimings = null;
        try {
            fileTimings = (paste) ? new PrintStream(bout) : new PrintStream(timings);

            CustomTimingsHandler.printTimings(fileTimings);
            fileTimings.println("Sample time " + sampleTime + " (" + sampleTime / 1E9 + "s)");

            fileTimings.println("<spigotConfig>");
            fileTimings.println(Bukkit.spigot().getConfig().saveToString());
            fileTimings.println("</spigotConfig>");

            if (paste) {
                new PasteThread(sender, bout).start();
                return;
            }

            sender.sendMessage("Timings written to " + timings.getPath());
            sender.sendMessage("Paste contents of file into form at http://www.spigotmc.org/go/timings to read results.");

        } catch (IOException e) {
        } finally {
            if (fileTimings != null) {
                fileTimings.close();
            }
        }
    }
}