count betterblockpos instantiation

This commit is contained in:
Leijurv
2018-09-21 22:10:25 -07:00
parent 2d288c7a47
commit 79bd26968a
2 changed files with 13 additions and 0 deletions
@@ -90,6 +90,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
HashMap<Class<? extends Movement>, Long> timeConsumed = new HashMap<>();
HashMap<Class<? extends Movement>, Integer> count = new HashMap<>();
HashMap<Class<? extends Movement>, Integer> stateLookup = new HashMap<>();
HashMap<Class<? extends Movement>, Long> posCreation = new HashMap<>();
long heapRemove = 0;
int heapRemoveCount = 0;
long heapAdd = 0;
@@ -161,9 +162,11 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
chunkCount++;
// TODO cache cost
int numLookupsBefore = BlockStateInterface.numBlockStateLookups;
long numCreatedBefore = BetterBlockPos.numCreated;
double actionCost = movementToGetToNeighbor.getCost(calcContext);
long costEnd = System.nanoTime();
stateLookup.put(movementToGetToNeighbor.getClass(), BlockStateInterface.numBlockStateLookups - numLookupsBefore + stateLookup.getOrDefault(movementToGetToNeighbor.getClass(), 0));
posCreation.put(movementToGetToNeighbor.getClass(), BetterBlockPos.numCreated - numCreatedBefore + posCreation.getOrDefault(movementToGetToNeighbor.getClass(), 0L));
timeConsumed.put(movementToGetToNeighbor.getClass(), costEnd - costStart + timeConsumed.getOrDefault(movementToGetToNeighbor.getClass(), 0L));
count.put(movementToGetToNeighbor.getClass(), 1 + count.getOrDefault(movementToGetToNeighbor.getClass(), 0));
numMovementsConsidered++;
@@ -240,6 +243,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
long nanoTime = timeConsumed.get(klass);
System.out.println(nanoTime / num + " " + klass + " " + nanoTime / 1000000 + "ms " + num);
System.out.println(stateLookup.get(klass) / num + " " + stateLookup.get(klass));
System.out.println(posCreation.get(klass) / num + " " + posCreation.get(klass));
}
if (cancelRequested) {
return Optional.empty();
@@ -36,6 +36,15 @@ public final class BetterBlockPos extends BlockPos {
public final int y;
public final int z;
public final long hashCode;
public static long numCreated;
static {
numCreated = 0;
}
{
numCreated++;
}
public BetterBlockPos(int x, int y, int z) {
super(x, y, z);