summaryrefslogtreecommitdiffstats
path: root/nms-patches/MethodProfiler.patch
blob: c4d954a25ea59107855aab438af30d334f1142bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
--- a/net/minecraft/server/MethodProfiler.java
+++ b/net/minecraft/server/MethodProfiler.java
@@ -13,6 +13,7 @@
 
 public class MethodProfiler {
 
+    public static final boolean ENABLED = Boolean.getBoolean("enableDebugMethodProfiler"); // CraftBukkit - disable unless specified in JVM arguments
     private static final Logger a = LogManager.getLogger();
     private final List<String> b = Lists.newArrayList();
     private final List<Long> c = Lists.newArrayList();
@@ -41,6 +42,7 @@
     }
 
     public void a(int i) {
+        if (!ENABLED) return; // CraftBukkit
         if (!this.d) {
             this.d = true;
             this.f.clear();
@@ -52,6 +54,7 @@
     }
 
     public void enter(String s) {
+        if (!ENABLED) return; // CraftBukkit
         if (this.d) {
             if (!this.e.isEmpty()) {
                 this.e = this.e + ".";
@@ -64,12 +67,14 @@
     }
 
     public void a(Supplier<String> supplier) {
+        if (!ENABLED) return; // CraftBukkit
         if (this.d) {
             this.enter((String) supplier.get());
         }
     }
 
     public void exit() {
+        if (!ENABLED) return; // CraftBukkit
         if (this.d && !this.c.isEmpty()) {
             long i = SystemUtils.getMonotonicNanos();
             long j = (Long) this.c.remove(this.c.size() - 1);
@@ -92,6 +97,7 @@
     }
 
     public List<MethodProfiler.ProfilerInfo> b(String s) {
+        if (!ENABLED) return Collections.emptyList(); // CraftBukkit
         long i = this.f.containsKey("root") ? (Long) this.f.get("root") : 0L;
         long j = this.f.containsKey(s) ? (Long) this.f.get(s) : -1L;
         ArrayList arraylist = Lists.newArrayList();
@@ -154,11 +160,13 @@
     }
 
     public void exitEnter(String s) {
+        if (!ENABLED) return; // CraftBukkit
         this.exit();
         this.enter(s);
     }
 
     public String f() {
+        if (!ENABLED) return "[DISABLED]"; // CraftBukkit
         return this.b.isEmpty() ? "[UNKNOWN]" : (String) this.b.get(this.b.size() - 1);
     }