Skip to content

Commit 1e027ff

Browse files
committed
some additional profiling for crafting modules
closes #230
1 parent 4a04535 commit 1e027ff

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/de/ellpeck/prettypipes/pipe/modules/craft/CraftingModuleItem.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ public List<ItemStack> getAllCraftables(ItemStack module, PipeBlockEntity tile)
175175
@Override
176176
public int getCraftableAmount(ItemStack module, PipeBlockEntity tile, Consumer<ItemStack> unavailableConsumer, ItemStack stack, Stack<ItemStack> dependencyChain) {
177177
var network = PipeNetwork.get(tile.getLevel());
178+
network.startProfile("get_craftable_amount");
178179
var items = network.getOrderedNetworkItems(tile.getBlockPos());
179180
var equalityTypes = ItemFilter.getEqualityTypes(tile);
180181
var content = module.get(Contents.TYPE);
@@ -189,6 +190,7 @@ public int getCraftableAmount(ItemStack module, PipeBlockEntity tile, Consumer<I
189190
craftable += out.getCount() * availableCrafts;
190191
}
191192
}
193+
network.endProfile();
192194
return craftable;
193195
}
194196

@@ -198,12 +200,14 @@ public Pair<ItemStack, Collection<ActiveCraft>> craft(ItemStack module, PipeBloc
198200
var craftableAmount = this.getCraftableAmount(module, tile, unavailableConsumer, stack, dependencyChain);
199201
if (craftableAmount <= 0)
200202
return Pair.of(stack, List.of());
201-
var slot = tile.getModuleSlot(module);
202-
var contents = module.get(Contents.TYPE);
203203

204204
var network = PipeNetwork.get(tile.getLevel());
205-
var items = network.getOrderedNetworkItems(tile.getBlockPos());
205+
network.startProfile("craft");
206206

207+
var items = network.getOrderedNetworkItems(tile.getBlockPos());
208+
var slot = tile.getModuleSlot(module);
209+
var contents = module.get(Contents.TYPE);
210+
207211
var equalityTypes = ItemFilter.getEqualityTypes(tile);
208212
var resultAmount = this.getResultAmountPerCraft(module, stack, equalityTypes);
209213
// calculate how many crafting *operations* to do (as opposed to how many *items* to craft)
@@ -246,6 +250,7 @@ public Pair<ItemStack, Collection<ActiveCraft>> craft(ItemStack module, PipeBloc
246250
allCrafts.add(activeCraft);
247251
leftOfRequest -= crafted;
248252
}
253+
network.endProfile();
249254

250255
var remain = stack.copy();
251256
remain.shrink(resultAmount * toCraft);

0 commit comments

Comments
 (0)