From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Ivan Pekov Date: Fri, 2 Oct 2020 17:48:01 +0300 Subject: [PATCH] Add JsonList save timings diff --git a/src/main/java/co/aikar/timings/MinecraftTimings.java b/src/main/java/co/aikar/timings/MinecraftTimings.java index 68ab5ccb2fcfe1de0503c9336572f28e11832b2d..d8c1a8dd867437443494ac169569139e25c9a635 100644 --- a/src/main/java/co/aikar/timings/MinecraftTimings.java +++ b/src/main/java/co/aikar/timings/MinecraftTimings.java @@ -149,4 +149,6 @@ public final class MinecraftTimings { public static Timing getCommandFunctionTiming(CustomFunction function) { return Timings.ofSafe("Command Function - " + function.getMinecraftKey().toString()); } + + public static Timing getJsonListTiming(String className) { return Timings.ofSafe("Save JsonList ( " + className + " )"); } // Yatopia } diff --git a/src/main/java/net/minecraft/server/JsonList.java b/src/main/java/net/minecraft/server/JsonList.java index 9213bfb78e92b838189161045e3945588251b486..4094ef76b7b05de1bfcc28aa0ef13033abadeb7e 100644 --- a/src/main/java/net/minecraft/server/JsonList.java +++ b/src/main/java/net/minecraft/server/JsonList.java @@ -44,9 +44,11 @@ public abstract class JsonList> { return null; } }; + private final co.aikar.timings.Timing saveTiming; // Yatopia public JsonList(File file) { this.c = file; + saveTiming = co.aikar.timings.MinecraftTimings.getJsonListTiming(getClass().getSimpleName()); // Yatopia } public File b() { @@ -146,6 +148,9 @@ public abstract class JsonList> { } public void save() throws IOException { + // Yatopia start + saveTiming.startTiming(); + try { // Yatopia end this.removeStaleEntries(); // Paper - remove expired values before saving JsonArray jsonarray = new JsonArray(); @@ -177,6 +182,9 @@ public abstract class JsonList> { } } + } finally { // Yatopia start + saveTiming.stopTiming(); + } // Yatopia end }