From c49b1fb7b60f419ec16b1f2ca55e507e0fbcc700 Mon Sep 17 00:00:00 2001 From: asofold Date: Mon, 4 Feb 2013 09:21:06 +0100 Subject: [PATCH] Change appearance of the output of the lag command. --- .../nocheatplus/command/admin/LagCommand.java | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/LagCommand.java b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/LagCommand.java index ffbbc13d..257278ee 100644 --- a/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/LagCommand.java +++ b/NCPPlugin/src/main/java/fr/neatmonster/nocheatplus/command/admin/LagCommand.java @@ -18,28 +18,25 @@ public class LagCommand extends NCPCommand { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - long max = 50L * (1L + TickTask.lagMaxTicks) * TickTask.lagMaxTicks; - long medium = 50L * TickTask.lagMaxTicks; - long second = 1200L; StringBuilder builder = new StringBuilder(300); - builder.append("Lag tracking (roughly):"); - builder.append("\nAverage lag:"); - for (long ms : new long[]{second, medium, max}){ - double lag = TickTask.getLag(ms); - int p = Math.max(0, (int) ((lag - 1.0) * 100.0)); - builder.append(" " + p + "%[" + StringUtil.fdec1.format((double) ms / 1200.0) + "s]" ); - } + builder.append("---- Lag tracking ----\n"); + // Lag spikes. long[] spikeDurations = TickTask.getLagSpikeDurations(); int[] spikes = TickTask.getLagSpikes(); - builder.append("\nLast hour spikes (" + spikes[0] + " total, all > " + spikeDurations[0] + " ms):\n| "); - if (spikes[0] > 0){ + builder.append("#### Lag spikes ####\n"); + if (spikes[0] == 0){ + builder.append("No spikes > " + spikeDurations[0] + " ms within the last 40 to 60 minutes."); + } + else if (spikes[0] > 0){ + builder.append("Total: " + spikes[0] + " > " + spikeDurations[0] + " ms within the last 40 to 60 minutes."); + builder.append("\n| "); for (int i = 0; i < spikeDurations.length; i++){ if (i < spikeDurations.length - 1 && spikes[i] == spikes[i + 1]){ // Ignore these, get printed later. continue; } if (spikes[i] == 0){ - builder.append("none |"); + continue; // Could be break. } else if (i < spikeDurations.length - 1){ builder.append((spikes[i] - spikes[i + 1]) + "x" + spikeDurations[i] + "..." + spikeDurations[i + 1] + " | "); @@ -49,9 +46,18 @@ public class LagCommand extends NCPCommand { } } } - else{ - builder.append("none | "); + builder.append("\n"); + // TPS lag. + long max = 50L * (1L + TickTask.lagMaxTicks) * TickTask.lagMaxTicks; + long medium = 50L * TickTask.lagMaxTicks; + long second = 1200L; + builder.append("#### TPS lag ####\nPerc.[time]:"); + for (long ms : new long[]{second, medium, max}){ + double lag = TickTask.getLag(ms); + int p = Math.max(0, (int) ((lag - 1.0) * 100.0)); + builder.append(" " + p + "%[" + StringUtil.fdec1.format((double) ms / 1200.0) + "s]" ); } + // Send message. sender.sendMessage(builder.toString()); return true; }