Elaborate on slow module

Not even my fault
This commit is contained in:
Minecon724 2025-01-03 13:54:48 +01:00
parent 648535fd22
commit a48fe97b4d
Signed by: Minecon724
GPG key ID: 3CCC4D267742C8E8

View file

@ -1,11 +1,12 @@
/* /*
* Copyright (C) 2024 Minecon724 * Copyright (C) 2025 Minecon724
* Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file * Tweaks724 is licensed under the GNU General Public License. See the LICENSE.md file
* in the project root for the full license text. * in the project root for the full license text.
*/ */
package eu.m724.tweaks.redstone; package eu.m724.tweaks.redstone;
import eu.m724.tweaks.DebugLogger;
import eu.m724.tweaks.Language; import eu.m724.tweaks.Language;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
@ -18,14 +19,21 @@ public class GatewayItem {
private final NamespacedKey gatewayKey; private final NamespacedKey gatewayKey;
public GatewayItem(Plugin plugin) { public GatewayItem(Plugin plugin) {
this.gatewayKey = new NamespacedKey(plugin, "gateway"); var start = System.nanoTime();
this.gatewayKey = new NamespacedKey(plugin, "gateway");
var recipe = new ShapelessRecipe(gatewayKey, itemStack()); var recipe = new ShapelessRecipe(gatewayKey, itemStack());
// this takes a long time for some reason. The first one especially
// do this somewhere off measure to JIT and skew the measurement: new RecipeChoice.MaterialChoice(Material.DIRT);
recipe.addIngredient(Material.NETHER_STAR); recipe.addIngredient(Material.NETHER_STAR);
recipe.addIngredient(Material.ENDER_CHEST); recipe.addIngredient(Material.ENDER_CHEST);
recipe.addIngredient(Material.CHORUS_FLOWER); recipe.addIngredient(Material.CHORUS_FLOWER);
recipe.addIngredient(Material.DAYLIGHT_DETECTOR); recipe.addIngredient(Material.DAYLIGHT_DETECTOR);
plugin.getServer().addRecipe(recipe); plugin.getServer().addRecipe(recipe);
DebugLogger.finer("Adding the recipe took %d ms, which is a long time", (System.nanoTime() - start) / 1000000);
} }
public ItemStack itemStack() { public ItemStack itemStack() {