From 1e027ff82536ec269ea23b39471c776a698077a9 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Wed, 4 Dec 2024 20:39:09 +0100 Subject: [PATCH] some additional profiling for crafting modules closes #230 --- .../pipe/modules/craft/CraftingModuleItem.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java b/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java index 03e6b82..a92c510 100644 --- a/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java +++ b/src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java @@ -175,6 +175,7 @@ public class CraftingModuleItem extends ModuleItem { @Override public int getCraftableAmount(ItemStack module, PipeBlockEntity tile, Consumer unavailableConsumer, ItemStack stack, Stack dependencyChain) { var network = PipeNetwork.get(tile.getLevel()); + network.startProfile("get_craftable_amount"); var items = network.getOrderedNetworkItems(tile.getBlockPos()); var equalityTypes = ItemFilter.getEqualityTypes(tile); var content = module.get(Contents.TYPE); @@ -189,6 +190,7 @@ public class CraftingModuleItem extends ModuleItem { craftable += out.getCount() * availableCrafts; } } + network.endProfile(); return craftable; } @@ -198,12 +200,14 @@ public class CraftingModuleItem extends ModuleItem { var craftableAmount = this.getCraftableAmount(module, tile, unavailableConsumer, stack, dependencyChain); if (craftableAmount <= 0) return Pair.of(stack, List.of()); - var slot = tile.getModuleSlot(module); - var contents = module.get(Contents.TYPE); var network = PipeNetwork.get(tile.getLevel()); - var items = network.getOrderedNetworkItems(tile.getBlockPos()); + network.startProfile("craft"); + var items = network.getOrderedNetworkItems(tile.getBlockPos()); + var slot = tile.getModuleSlot(module); + var contents = module.get(Contents.TYPE); + var equalityTypes = ItemFilter.getEqualityTypes(tile); var resultAmount = this.getResultAmountPerCraft(module, stack, equalityTypes); // calculate how many crafting *operations* to do (as opposed to how many *items* to craft) @@ -246,6 +250,7 @@ public class CraftingModuleItem extends ModuleItem { allCrafts.add(activeCraft); leftOfRequest -= crafted; } + network.endProfile(); var remain = stack.copy(); remain.shrink(resultAmount * toCraft);