3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-11-16 21:10:17 +01:00
Paper/nms-patches/MethodProfiler.patch

64 Zeilen
2.0 KiB
Diff

2015-05-25 12:37:24 +02:00
--- a/net/minecraft/server/MethodProfiler.java
+++ b/net/minecraft/server/MethodProfiler.java
2018-12-25 22:00:00 +01:00
@@ -12,6 +12,7 @@
public class MethodProfiler {
2015-02-26 23:41:06 +01:00
+ public static final boolean ENABLED = Boolean.getBoolean("enableDebugMethodProfiler"); // CraftBukkit - disable unless specified in JVM arguments
2018-07-15 02:00:00 +02:00
private static final Logger a = LogManager.getLogger();
private final List<String> b = Lists.newArrayList();
private final List<Long> c = Lists.newArrayList();
2018-12-25 22:00:00 +01:00
@@ -40,6 +41,7 @@
2018-07-15 02:00:00 +02:00
}
2018-07-15 02:00:00 +02:00
public void a(int i) {
+ if (!ENABLED) return; // CraftBukkit
if (!this.d) {
this.d = true;
this.f.clear();
2018-12-25 22:00:00 +01:00
@@ -51,6 +53,7 @@
}
2018-12-13 01:00:00 +01:00
public void enter(String s) {
2018-07-15 02:00:00 +02:00
+ if (!ENABLED) return; // CraftBukkit
if (this.d) {
2017-05-14 04:00:00 +02:00
if (!this.e.isEmpty()) {
this.e = this.e + ".";
2018-12-25 22:00:00 +01:00
@@ -63,12 +66,14 @@
2017-08-03 15:00:00 +02:00
}
public void a(Supplier<String> supplier) {
2018-07-15 02:00:00 +02:00
+ if (!ENABLED) return; // CraftBukkit
if (this.d) {
2018-12-13 01:00:00 +01:00
this.enter((String) supplier.get());
2017-08-03 15:00:00 +02:00
}
}
2018-12-13 01:00:00 +01:00
public void exit() {
2018-07-15 02:00:00 +02:00
+ if (!ENABLED) return; // CraftBukkit
if (this.d && !this.c.isEmpty()) {
2018-12-13 01:00:00 +01:00
long i = SystemUtils.getMonotonicNanos();
2018-12-06 00:00:00 +01:00
long j = (Long) this.c.remove(this.c.size() - 1);
2018-12-25 22:00:00 +01:00
@@ -91,6 +96,7 @@
}
2015-02-26 23:41:06 +01:00
public List<MethodProfiler.ProfilerInfo> b(String s) {
2018-07-15 02:00:00 +02:00
+ if (!ENABLED) return Collections.emptyList(); // CraftBukkit
2018-12-06 00:00:00 +01:00
long i = this.f.containsKey("root") ? (Long) this.f.get("root") : 0L;
long j = this.f.containsKey(s) ? (Long) this.f.get(s) : -1L;
2018-12-25 22:00:00 +01:00
List<MethodProfiler.ProfilerInfo> list = Lists.newArrayList();
@@ -153,11 +159,13 @@
}
2018-12-13 01:00:00 +01:00
public void exitEnter(String s) {
2018-07-15 02:00:00 +02:00
+ if (!ENABLED) return; // CraftBukkit
2018-12-13 01:00:00 +01:00
this.exit();
this.enter(s);
}
2018-07-15 02:00:00 +02:00
public String f() {
+ if (!ENABLED) return "[DISABLED]"; // CraftBukkit
return this.b.isEmpty() ? "[UNKNOWN]" : (String) this.b.get(this.b.size() - 1);
2015-02-26 23:41:06 +01:00
}