From b7004609991dab287b582a1546a1b59c5d90c916 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Wed, 24 Jan 2024 16:27:32 +0000 Subject: [PATCH] Convert average tick value in the GUI to the correct granularity --- patches/server/0331-Make-the-GUI-graph-fancier.patch | 7 ++++--- patches/server/0520-Improve-ServerGUI.patch | 9 ++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/patches/server/0331-Make-the-GUI-graph-fancier.patch b/patches/server/0331-Make-the-GUI-graph-fancier.patch index b727ad1c2c..a997709470 100644 --- a/patches/server/0331-Make-the-GUI-graph-fancier.patch +++ b/patches/server/0331-Make-the-GUI-graph-fancier.patch @@ -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; @@ -221,7 +222,7 @@ index 0000000000000000000000000000000000000000..48e0b8a50090735ac44d03bdff22010c + Vector 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); + } + diff --git a/patches/server/0520-Improve-ServerGUI.patch b/patches/server/0520-Improve-ServerGUI.patch index 9d032f6712..6387ce2d2d 100644 --- a/patches/server/0520-Improve-ServerGUI.patch +++ b/patches/server/0520-Improve-ServerGUI.patch @@ -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 { +@@ -58,9 +58,17 @@ public class RAMDetails extends JList { public void update() { GraphData data = RAMGraph.DATA.peekLast(); Vector 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("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 { +@@ -71,4 +79,8 @@ public class RAMDetails extends JList { } return ((double) total / (double) tickTimes.length) * 1.0E-6D; }