mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appears to apply and compile correctly Paper Changes: ab74bb45 Speed up processing of chunk loads and generation f5dd491f Increase Light Queue Size 9ab69348 Don't load chunks when attempting to unload a chunk 38c62622 Improve Optimize Memory use logic to make iterator safer and fix bad plugins like P2
95 lines
3.2 KiB
Diff
95 lines
3.2 KiB
Diff
From 6f706722898460ae8b2a24a3782e2353cb6509e7 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Thu, 30 Jan 2020 00:41:24 -0600
|
|
Subject: [PATCH] Add tick times API
|
|
|
|
---
|
|
.../net/minecraft/server/MinecraftServer.java | 37 +++++++++++++++++++
|
|
.../org/bukkit/craftbukkit/CraftServer.java | 12 ++++++
|
|
2 files changed, 49 insertions(+)
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index 63cc289e44..e4b1eabd77 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -106,6 +106,11 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
private int G;
|
|
private int H;
|
|
public final long[] f = new long[100]; public long[] getTickTimes() { return f; } // Paper - OBFHELPER
|
|
+ // Purpur start
|
|
+ public final TickTimes tickTimes5s = new TickTimes(100);
|
|
+ public final TickTimes tickTimes10s = new TickTimes(200);
|
|
+ public final TickTimes tickTimes60s = new TickTimes(1200);
|
|
+ // Purpur end
|
|
@Nullable
|
|
private KeyPair I;
|
|
@Nullable
|
|
@@ -1175,6 +1180,12 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
this.methodProfiler.enter("tallying");
|
|
long l = this.f[this.ticks % 100] = SystemUtils.getMonotonicNanos() - i;
|
|
|
|
+ // Purpur start
|
|
+ tickTimes5s.add(this.ticks % 100, l);
|
|
+ tickTimes10s.add(this.ticks % 200, l);
|
|
+ tickTimes60s.add(this.ticks % 1200, l);
|
|
+ // Purpur end
|
|
+
|
|
this.av = this.av * 0.8F + (float) l / 1000000.0F * 0.19999999F;
|
|
long i1 = SystemUtils.getMonotonicNanos();
|
|
|
|
@@ -2270,4 +2281,30 @@ public abstract class MinecraftServer extends IAsyncTaskHandlerReentrant<TickTas
|
|
return SERVER; // Paper
|
|
}
|
|
// CraftBukkit end
|
|
+
|
|
+ // Purpur start
|
|
+ public static class TickTimes {
|
|
+ private final long[] times;
|
|
+
|
|
+ public TickTimes(int length) {
|
|
+ times = new long[length];
|
|
+ }
|
|
+
|
|
+ void add(int index, long time) {
|
|
+ times[index] = time;
|
|
+ }
|
|
+
|
|
+ public long[] getTimes() {
|
|
+ return times.clone();
|
|
+ }
|
|
+
|
|
+ public double getAverage() {
|
|
+ long total = 0L;
|
|
+ for (long value : times) {
|
|
+ total += value;
|
|
+ }
|
|
+ return ((double) total / (double) times.length) * 1.0E-6D;
|
|
+ }
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
index ea43602eb4..cea28154e2 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
|
|
@@ -2223,4 +2223,16 @@ public final class CraftServer implements Server {
|
|
return net.minecraft.server.MinecraftServer.currentTick;
|
|
}
|
|
// Paper end
|
|
+
|
|
+ // Purpur start
|
|
+ @Override
|
|
+ public long[] getTickTimes() {
|
|
+ return getServer().tickTimes5s.getTimes();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public double getAverageTickTime() {
|
|
+ return getServer().tickTimes5s.getAverage();
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
--
|
|
2.24.0
|
|
|