bench the whole loop

This commit is contained in:
Leijurv 2018-08-29 14:46:58 -07:00
parent 27aeba3f8b
commit a753fe5df9
No known key found for this signature in database
GPG Key ID: 44A3EA646EADAC6A
1 changed files with 7 additions and 3 deletions

View File

@ -96,8 +96,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
long chunk = 0;
int chunkCount = 0;
long chunk2 = 0;
int chunkCount2 = 0;
long goalCheck = 0;
int goalCheckCount = 0;
long getNode = 0;
int getNodeCount = 0;
@ -110,7 +110,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
}
long before = System.nanoTime();
PathNode currentNode = openSet.removeLowest();
heapRemove += System.nanoTime() - before;
long t = System.nanoTime();
heapRemove += t - before;
heapRemoveCount++;
currentNode.isOpen = false;
mostRecentConsidered = currentNode;
@ -126,6 +127,8 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
return Optional.of(new Path(startNode, currentNode, numNodes));
}
long constructStart = System.nanoTime();
goalCheck += constructStart - t;
goalCheckCount++;
Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order
shuffle(possibleMovements);
long constructEnd = System.nanoTime();
@ -220,6 +223,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
System.out.println("Construction " + (construction / constructionCount) + " " + construction / 1000000 + " " + constructionCount);
System.out.println("Chunk " + (chunk / chunkCount) + " " + chunk / 1000000 + " " + chunkCount);
System.out.println("GetNode " + (getNode / getNodeCount) + " " + getNode / 1000000 + " " + getNodeCount);
System.out.println("GoalCheck " + (goalCheck / goalCheckCount) + " " + goalCheck / 1000000 + " " + goalCheckCount);
ArrayList<Class<? extends Movement>> klasses = new ArrayList<>(count.keySet());
klasses.sort(Comparator.comparingLong(k -> timeConsumed.get(k) / count.get(k)));
for (Class<? extends Movement> klass : klasses) {