format
This commit is contained in:
@@ -82,24 +82,24 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
boolean minimumImprovementRepropagation = Baritone.settings().minimumImprovementRepropagation.get();
|
boolean minimumImprovementRepropagation = Baritone.settings().minimumImprovementRepropagation.get();
|
||||||
HashMap<Class<? extends Movement>, Long> timeConsumed = new HashMap<>();
|
HashMap<Class<? extends Movement>, Long> timeConsumed = new HashMap<>();
|
||||||
HashMap<Class<? extends Movement>, Integer> count = new HashMap<>();
|
HashMap<Class<? extends Movement>, Integer> count = new HashMap<>();
|
||||||
long heapRemove=0;
|
long heapRemove = 0;
|
||||||
int heapRemoveCount=0;
|
int heapRemoveCount = 0;
|
||||||
long heapAdd=0;
|
long heapAdd = 0;
|
||||||
int heapAddCount=0;
|
int heapAddCount = 0;
|
||||||
long heapUpdate=0;
|
long heapUpdate = 0;
|
||||||
int heapUpdateCount=0;
|
int heapUpdateCount = 0;
|
||||||
|
|
||||||
long construction=0;
|
long construction = 0;
|
||||||
int constructionCount=0;
|
int constructionCount = 0;
|
||||||
|
|
||||||
long chunk=0;
|
long chunk = 0;
|
||||||
int chunkCount=0;
|
int chunkCount = 0;
|
||||||
|
|
||||||
long chunk2=0;
|
long chunk2 = 0;
|
||||||
int chunkCount2=0;
|
int chunkCount2 = 0;
|
||||||
|
|
||||||
long getNode=0;
|
long getNode = 0;
|
||||||
int getNodeCount=0;
|
int getNodeCount = 0;
|
||||||
while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && System.currentTimeMillis() < timeoutTime && !cancelRequested) {
|
while (!openSet.isEmpty() && numEmptyChunk < pathingMaxChunkBorderFetch && System.currentTimeMillis() < timeoutTime && !cancelRequested) {
|
||||||
if (slowPath) {
|
if (slowPath) {
|
||||||
try {
|
try {
|
||||||
@@ -107,9 +107,9 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
} catch (InterruptedException ex) {
|
} catch (InterruptedException ex) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long before=System.nanoTime();
|
long before = System.nanoTime();
|
||||||
PathNode currentNode = openSet.removeLowest();
|
PathNode currentNode = openSet.removeLowest();
|
||||||
heapRemove+=System.nanoTime()-before;
|
heapRemove += System.nanoTime() - before;
|
||||||
heapRemoveCount++;
|
heapRemoveCount++;
|
||||||
currentNode.isOpen = false;
|
currentNode.isOpen = false;
|
||||||
mostRecentConsidered = currentNode;
|
mostRecentConsidered = currentNode;
|
||||||
@@ -127,7 +127,7 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order
|
Movement[] possibleMovements = getConnectedPositions(currentNodePos, calcContext);//movement that we could take that start at currentNodePos, in random order
|
||||||
shuffle(possibleMovements);
|
shuffle(possibleMovements);
|
||||||
long constructEnd = System.nanoTime();
|
long constructEnd = System.nanoTime();
|
||||||
construction+=constructEnd-constructStart;
|
construction += constructEnd - constructStart;
|
||||||
constructionCount++;
|
constructionCount++;
|
||||||
//System.out.println(constructEnd - constructStart);
|
//System.out.println(constructEnd - constructStart);
|
||||||
for (Movement movementToGetToNeighbor : possibleMovements) {
|
for (Movement movementToGetToNeighbor : possibleMovements) {
|
||||||
@@ -135,19 +135,19 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
BetterBlockPos dest = (BetterBlockPos) movementToGetToNeighbor.getDest();
|
BetterBlockPos dest = (BetterBlockPos) movementToGetToNeighbor.getDest();
|
||||||
long s=System.nanoTime();
|
long s = System.nanoTime();
|
||||||
boolean isPositionCached = false;
|
boolean isPositionCached = false;
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
if (world.isCached(dest)) {
|
if (world.isCached(dest)) {
|
||||||
isPositionCached = true;
|
isPositionCached = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long k=System.nanoTime();
|
long k = System.nanoTime();
|
||||||
chunk2+=k-s;
|
chunk2 += k - s;
|
||||||
chunkCount2++;
|
chunkCount2++;
|
||||||
boolean currentlyLoaded=Minecraft.getMinecraft().world.getChunk(dest) instanceof EmptyChunk;
|
boolean currentlyLoaded = Minecraft.getMinecraft().world.getChunk(dest) instanceof EmptyChunk;
|
||||||
long costStart = System.nanoTime();
|
long costStart = System.nanoTime();
|
||||||
chunk+=costStart-k;
|
chunk += costStart - k;
|
||||||
chunkCount++;
|
chunkCount++;
|
||||||
if (!isPositionCached && currentlyLoaded) {
|
if (!isPositionCached && currentlyLoaded) {
|
||||||
numEmptyChunk++;
|
numEmptyChunk++;
|
||||||
@@ -171,9 +171,9 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
// see issue #18
|
// see issue #18
|
||||||
actionCost *= favorCoeff;
|
actionCost *= favorCoeff;
|
||||||
}
|
}
|
||||||
long st=System.nanoTime();
|
long st = System.nanoTime();
|
||||||
PathNode neighbor = getNodeAtPosition(dest);
|
PathNode neighbor = getNodeAtPosition(dest);
|
||||||
getNode+=System.nanoTime()-st;
|
getNode += System.nanoTime() - st;
|
||||||
getNodeCount++;
|
getNodeCount++;
|
||||||
double tentativeCost = currentNode.cost + actionCost;
|
double tentativeCost = currentNode.cost + actionCost;
|
||||||
if (tentativeCost < neighbor.cost) {
|
if (tentativeCost < neighbor.cost) {
|
||||||
@@ -193,14 +193,14 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
neighbor.cost = tentativeCost;
|
neighbor.cost = tentativeCost;
|
||||||
neighbor.combinedCost = tentativeCost + neighbor.estimatedCostToGoal;
|
neighbor.combinedCost = tentativeCost + neighbor.estimatedCostToGoal;
|
||||||
if (neighbor.isOpen) {
|
if (neighbor.isOpen) {
|
||||||
long bef=System.nanoTime();
|
long bef = System.nanoTime();
|
||||||
openSet.update(neighbor);
|
openSet.update(neighbor);
|
||||||
heapUpdate+=System.nanoTime()-bef;
|
heapUpdate += System.nanoTime() - bef;
|
||||||
heapUpdateCount++;
|
heapUpdateCount++;
|
||||||
} else {
|
} else {
|
||||||
long bef=System.nanoTime();
|
long bef = System.nanoTime();
|
||||||
openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there
|
openSet.insert(neighbor);//dont double count, dont insert into open set if it's already there
|
||||||
heapAdd+=System.nanoTime()-bef;
|
heapAdd += System.nanoTime() - bef;
|
||||||
heapAddCount++;
|
heapAddCount++;
|
||||||
neighbor.isOpen = true;
|
neighbor.isOpen = true;
|
||||||
}
|
}
|
||||||
@@ -214,19 +214,19 @@ public class AStarPathFinder extends AbstractNodeCostSearch implements Helper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
System.out.println("Remove "+(heapRemove/heapRemoveCount)+" "+heapRemove/1000000+" "+heapRemoveCount);
|
System.out.println("Remove " + (heapRemove / heapRemoveCount) + " " + heapRemove / 1000000 + " " + heapRemoveCount);
|
||||||
System.out.println("Add "+(heapAdd/heapAddCount)+" "+heapAdd/1000000+" "+heapAddCount);
|
System.out.println("Add " + (heapAdd / heapAddCount) + " " + heapAdd / 1000000 + " " + heapAddCount);
|
||||||
System.out.println("Update "+(heapUpdate/heapUpdateCount)+" "+heapUpdate/1000000+" "+heapUpdateCount);
|
System.out.println("Update " + (heapUpdate / heapUpdateCount) + " " + heapUpdate / 1000000 + " " + heapUpdateCount);
|
||||||
System.out.println("Construction "+(construction/constructionCount)+" "+construction/1000000+" "+constructionCount);
|
System.out.println("Construction " + (construction / constructionCount) + " " + construction / 1000000 + " " + constructionCount);
|
||||||
System.out.println("EmptyChunk "+(chunk/chunkCount)+" "+chunk/1000000+" "+chunkCount);
|
System.out.println("EmptyChunk " + (chunk / chunkCount) + " " + chunk / 1000000 + " " + chunkCount);
|
||||||
System.out.println("CachedChunk "+(chunk2/chunkCount2)+" "+chunk2/1000000+" "+chunkCount2);
|
System.out.println("CachedChunk " + (chunk2 / chunkCount2) + " " + chunk2 / 1000000 + " " + chunkCount2);
|
||||||
System.out.println("GetNode "+(getNode/getNodeCount)+" "+getNode/1000000+" "+getNodeCount);
|
System.out.println("GetNode " + (getNode / getNodeCount) + " " + getNode / 1000000 + " " + getNodeCount);
|
||||||
ArrayList<Class<? extends Movement>> klasses = new ArrayList<>(count.keySet());
|
ArrayList<Class<? extends Movement>> klasses = new ArrayList<>(count.keySet());
|
||||||
klasses.sort(Comparator.comparingLong(k -> timeConsumed.get(k) / count.get(k)));
|
klasses.sort(Comparator.comparingLong(k -> timeConsumed.get(k) / count.get(k)));
|
||||||
for (Class<? extends Movement> klass : klasses) {
|
for (Class<? extends Movement> klass : klasses) {
|
||||||
int num = count.get(klass);
|
int num = count.get(klass);
|
||||||
long nanoTime = timeConsumed.get(klass);
|
long nanoTime = timeConsumed.get(klass);
|
||||||
System.out.println(nanoTime / num + " " + klass + " " + nanoTime/1000000 + "ms " + num);
|
System.out.println(nanoTime / num + " " + klass + " " + nanoTime / 1000000 + "ms " + num);
|
||||||
}
|
}
|
||||||
if (cancelRequested) {
|
if (cancelRequested) {
|
||||||
currentlyRunning = null;
|
currentlyRunning = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user