Skip to content

Commit

Permalink
Convert average tick value in the GUI to the correct granularity
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicboy committed Jan 24, 2024
1 parent a4a08b7 commit b700460
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 4 additions & 3 deletions patches/server/0331-Make-the-GUI-graph-fancier.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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
new file mode 100644
index 0000000000000000000000000000000000000000..48e0b8a50090735ac44d03bdff22010c60b0d7e5
index 0000000000000000000000000000000000000000..f93373d28d741e1f8a53e07b4e328ce9c4e1657f
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/gui/RAMDetails.java
@@ -0,0 +1,73 @@
@@ -0,0 +1,74 @@
+package com.destroystokyo.paper.gui;
+
+import net.minecraft.Util;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.util.TimeUtil;
+
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.DefaultListSelectionModel;
Expand Down Expand Up @@ -221,7 +222,7 @@ index 0000000000000000000000000000000000000000..48e0b8a50090735ac44d03bdff22010c
+ Vector<String> vector = new Vector<>();
+ 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("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);
+ }
+
Expand Down
9 changes: 4 additions & 5 deletions patches/server/0520-Improve-ServerGUI.patch
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ Subject: [PATCH] Improve ServerGUI
- 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
index 48e0b8a50090735ac44d03bdff22010c60b0d7e5..066b9e4c4f0e7773548eda045cdd1ca8445221d2 100644
index f93373d28d741e1f8a53e07b4e328ce9c4e1657f..cac68122f2f816674173cd8057107ad6875c6d3b 100644
--- a/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() {
GraphData data = RAMGraph.DATA.peekLast();
Vector<String> vector = new Vector<>();
Expand All @@ -23,13 +23,12 @@ index 48e0b8a50090735ac44d03bdff22010c60b0d7e5..066b9e4c4f0e7773548eda045cdd1ca8
+ }
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("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));
+
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;
}
Expand Down

0 comments on commit b700460

Please sign in to comment.