Added benchmark
This commit is contained in:
@@ -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()){
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user