Convert average tick value in the GUI to the correct granularity

This commit is contained in:
Shane Freeder 2024-01-24 16:27:32 +00:00
parent a4a08b7342
commit b700460999
No known key found for this signature in database
GPG key ID: A3F61EA5A085289C
2 changed files with 8 additions and 8 deletions

View file

@ -156,14 +156,15 @@ index 0000000000000000000000000000000000000000..537bc6213545e8ff1b7b51bc4b27fd5b
+} +}
diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..48e0b8a50090735ac44d03bdff22010c60b0d7e5 index 0000000000000000000000000000000000000000..f93373d28d741e1f8a53e07b4e328ce9c4e1657f
--- /dev/null --- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java +++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
@@ -0,0 +1,73 @@ @@ -0,0 +1,74 @@
+package com.destroystokyo.paper.gui; +package com.destroystokyo.paper.gui;
+ +
+import net.minecraft.Util; +import net.minecraft.Util;
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.TimeUtil;
+ +
+import javax.swing.DefaultListCellRenderer; +import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListSelectionModel; +import javax.swing.DefaultListSelectionModel;
@ -221,7 +222,7 @@ index 0000000000000000000000000000000000000000..48e0b8a50090735ac44d03bdff22010c
+ Vector<String> vector = new Vector<>(); + Vector<String> vector = new Vector<>();
+ vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)"); + vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)");
+ vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb"); + vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb");
+ vector.add("Avg tick: " + DECIMAL_FORMAT.format(this.getAverage(server.getTickTimesNanos())) + " ms"); + vector.add("Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / (double) TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms");
+ setListData(vector); + setListData(vector);
+ } + }
+ +

View file

@ -7,10 +7,10 @@ Subject: [PATCH] Improve ServerGUI
- Show tps in the server stats - Show tps in the server stats
diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java diff --git a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
index 48e0b8a50090735ac44d03bdff22010c60b0d7e5..066b9e4c4f0e7773548eda045cdd1ca8445221d2 100644 index f93373d28d741e1f8a53e07b4e328ce9c4e1657f..cac68122f2f816674173cd8057107ad6875c6d3b 100644
--- a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java --- a/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
+++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java +++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
@@ -57,9 +57,18 @@ public class RAMDetails extends JList<String> { @@ -58,9 +58,17 @@ public class RAMDetails extends JList<String> {
public void update() { public void update() {
GraphData data = RAMGraph.DATA.peekLast(); GraphData data = RAMGraph.DATA.peekLast();
Vector<String> vector = new Vector<>(); Vector<String> vector = new Vector<>();
@ -23,13 +23,12 @@ index 48e0b8a50090735ac44d03bdff22010c60b0d7e5..066b9e4c4f0e7773548eda045cdd1ca8
+ } + }
vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)"); vector.add("Memory use: " + (data.getUsedMem() / 1024L / 1024L) + " mb (" + (data.getFree() * 100L / data.getMax()) + "% free)");
vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb"); vector.add("Heap: " + (data.getTotal() / 1024L / 1024L) + " / " + (data.getMax() / 1024L / 1024L) + " mb");
vector.add("Avg tick: " + DECIMAL_FORMAT.format(this.getAverage(server.getTickTimesNanos())) + " ms"); vector.add("Avg tick: " + DECIMAL_FORMAT.format((double)this.server.getAverageTickTimeNanos() / (double) TimeUtil.NANOSECONDS_PER_MILLISECOND) + " ms");
+ vector.add("TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg)); + vector.add("TPS from last 1m, 5m, 15m: " + String.join(", ", tpsAvg));
+
setListData(vector); setListData(vector);
} }
@@ -70,4 +79,8 @@ public class RAMDetails extends JList<String> { @@ -71,4 +79,8 @@ public class RAMDetails extends JList<String> {
} }
return ((double) total / (double) tickTimes.length) * 1.0E-6D; return ((double) total / (double) tickTimes.length) * 1.0E-6D;
} }