Added benchmark

This commit is contained in:
Anuken
2018-01-05 13:17:13 -05:00
parent cef85e8f36
commit ba2cfc2820
2 changed files with 24 additions and 1 deletions

View File

@@ -10,12 +10,14 @@ import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.entities.enemies.EnemyType;
import io.anuke.mindustry.world.SpawnPoint;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.UCore;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
import io.anuke.ucore.util.Tmp;
public class Pathfind{
private static final long ms = 1000000 * 5;
private static final long ms = 1000000 * 500;
MHueristic heuristic = new MHueristic();
PassTileGraph graph = new PassTileGraph();
@@ -122,6 +124,23 @@ public class Pathfind{
}
}
public void benchmark(){
SpawnPoint point = Vars.control.getSpawnPoints().first();
//warmup
for(int i = 0; i < 100; i ++){
point.finder.searchNodePath(point.start, Vars.control.getCore(), heuristic, point.path);
point.path.clear();
}
Timers.mark();
for(int i = 0; i < 100; i ++){
point.finder.searchNodePath(point.start, Vars.control.getCore(), heuristic, point.path);
point.path.clear();
}
UCore.log("Time elapsed: " + Timers.elapsed() + "ms");
}
public boolean finishedUpdating(){
for(SpawnPoint point : Vars.control.getSpawnPoints()){

View File

@@ -579,6 +579,10 @@ public class Control extends Module{
wavetime = 0f;
}
if(Inputs.keyTap(Keys.G)){
world.pathfinder().benchmark();
}
if(Inputs.keyDown(Keys.I)){
wavetime -= delta() * 10f;
}