Skip to content

Instantly share code, notes, and snippets.

@Shadows-of-Fire
Last active April 28, 2021 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shadows-of-Fire/ad55164cbd41ed4ca897b2099a62f2a6 to your computer and use it in GitHub Desktop.
Save Shadows-of-Fire/ad55164cbd41ed4ca897b2099a62f2a6 to your computer and use it in GitHub Desktop.
(Time values are in microseconds)
FastSuite (Cache Size 100):
Seek Times for Recipe iron nugget : [108, 44, 47, 37, 72, 44, 22, 21, 21, 18]
Seek Times for Recipe sticks : [1287, 1, 1, 1, 1, 2, 2, 1, 1, 1]
Seek Times for Recipe crafting table : [151, 0, 0, 0, 0, 1, 0, 0, 0, 0]
Seek Times for Recipe acacia planks : [4831, 12, 10, 10, 8, 17, 8, 10, 4, 4]
Seek Times for Recipe failure : [657, 344, 333, 306, 277, 372, 219, 189, 182, 180]
Seek Times for Recipe gold nugget : [29, 24, 26, 19, 68, 88, 20, 12, 12, 11]
Vanilla:
Seek Times for Recipe iron nugget : [40, 81, 26, 19, 27, 57, 18, 19, 23, 17]
Seek Times for Recipe sticks : [1304, 233, 278, 160, 143, 266, 137, 120, 130, 139]
Seek Times for Recipe crafting table : [124, 76, 80, 63, 67, 110, 58, 75, 56, 57]
Seek Times for Recipe acacia planks : [4764, 377, 930, 219, 228, 378, 218, 170, 181, 195]
Seek Times for Recipe failure : [467, 409, 277, 199, 232, 513, 263, 184, 185, 180]
Seek Times for Recipe gold nugget : [23, 25, 72, 11, 14, 32, 16, 13, 11, 10]
FastSuite (Cache Size 1):
Seek Times for Recipe iron nugget : [96, 28, 26, 30, 21, 154, 7, 5, 5, 4]
Seek Times for Recipe sticks : [1074, 5, 2, 4, 4, 4, 3, 2, 2, 2]
Seek Times for Recipe crafting table : [87, 2, 2, 5, 5, 3, 2, 2, 2, 2]
Seek Times for Recipe acacia planks : [4763, 28, 17, 22, 19, 15, 15, 5, 4, 5]
Seek Times for Recipe failure : [551, 521, 511, 570, 480, 337, 180, 185, 336, 152]
Seek Times for Recipe gold nugget : [32, 34, 27, 183, 47, 114, 7, 7, 7, 7]
public void test(FMLServerStartedEvent e) {
RecipeManager mgr = e.getServer().getRecipeManager();
World world = e.getServer().getWorld(World.OVERWORLD);
CraftingInventory acPlankInv = cInv();
CraftingInventory crafTableInv = cInv();
CraftingInventory stickInv = cInv();
CraftingInventory badInv = cInv();
CraftingInventory gnInv = cInv();
CraftingInventory inInv = cInv();
CraftingInventory empty = cInv();
acPlankInv.setInventorySlotContents(0, new ItemStack(Items.ACACIA_LOG));
stickInv.setInventorySlotContents(0, new ItemStack(Items.BIRCH_PLANKS));
stickInv.setInventorySlotContents(3, new ItemStack(Items.BIRCH_PLANKS));
for (int i = 0; i < 2; i++) {
crafTableInv.setInventorySlotContents(i, new ItemStack(Items.OAK_PLANKS));
crafTableInv.setInventorySlotContents(i + 3, new ItemStack(Items.OAK_PLANKS));
}
badInv.setInventorySlotContents(0, new ItemStack(Items.CROSSBOW));
gnInv.setInventorySlotContents(0, new ItemStack(Items.IRON_INGOT));
inInv.setInventorySlotContents(0, new ItemStack(Items.GOLD_INGOT));
for (int i = 0; i < 100; i++) { //Prime the thing to make sure everything is classloaded and friendly.
mgr.getRecipe(IRecipeType.CRAFTING, empty, world);
}
CraftingInventory[] arr = { acPlankInv, stickInv, crafTableInv, badInv, gnInv, inInv };
String[] names = { "acacia planks", "sticks", "crafting table", "failure", "gold nugget", "iron nugget" };
Map<String, ArrayList<Long>> times = new HashMap<>();
long time, time2;
for (int i = 0; i < 60; i++) {
int j = i % 6;
time = System.nanoTime();
mgr.getRecipe(IRecipeType.CRAFTING, arr[j], world);
time2 = System.nanoTime();
times.computeIfAbsent(names[j], s -> new ArrayList<>()).add((time2 - time) / 1000L);
}
for (Map.Entry<String, ArrayList<Long>> ent : times.entrySet()) {
LOG.info("Seek Times for Recipe {} : {}", ent.getKey(), Arrays.toString(ent.getValue().toArray(new Long[0])));
}
}
CraftingInventory cInv() {
return new CraftingInventory(new Container(null, -1) {
public boolean canInteractWith(PlayerEntity playerIn) {
return false;
}
}, 3, 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment