feat(time-trial): output csv data
This commit is contained in:
parent
017d65f57c
commit
7545364b39
1 changed files with 22 additions and 7 deletions
|
@ -15,21 +15,35 @@ import org.insa.graphs.model.io.BinaryGraphReader;
|
||||||
import org.insa.graphs.model.io.GraphReader;
|
import org.insa.graphs.model.io.GraphReader;
|
||||||
|
|
||||||
public class RunTimeTrial {
|
public class RunTimeTrial {
|
||||||
final static int TEST_COUNT = 10;
|
final static int TEST_COUNT = 100;
|
||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
final Graph graph = readGraph("./Maps/france.mapgr");
|
final Graph graph = readGraph("./Maps/midi-pyrenees.mapgr");
|
||||||
|
|
||||||
long totalDijkstraTime = 0;
|
long totalDijkstraTime = 0;
|
||||||
long totalAStarTime = 0;
|
long totalAStarTime = 0;
|
||||||
long totalBellmanTime = 0;
|
long totalBellmanTime = 0;
|
||||||
|
|
||||||
|
System.err.println("N D A B");
|
||||||
|
|
||||||
for (int i = 0; i < TEST_COUNT; i++) {
|
for (int i = 0; i < TEST_COUNT; i++) {
|
||||||
System.out.println("Running time trial " + i + "/" + TEST_COUNT);
|
//System.out.println("Running time trial " + i + "/" + TEST_COUNT);
|
||||||
final ShortestPathData data = getRandomShortestPathData(graph);
|
final ShortestPathData data = getRandomShortestPathData(graph);
|
||||||
totalDijkstraTime += new DijkstraAlgorithm(data).run().getSolvingTime().toMillis();
|
|
||||||
totalAStarTime += new AStarAlgorithm(data).run().getSolvingTime().toMillis();
|
ShortestPathSolution dijkstraSolution = new DijkstraAlgorithm(data).run();
|
||||||
//totalBellmanTime += new BellmanFordAlgorithm(data).run().getSolvingTime().toMillis();
|
ShortestPathSolution aStarSolution = new AStarAlgorithm(data).run();
|
||||||
|
//ShortestPathSolution bellmanSolution = new BellmanFordAlgorithm(data).run();
|
||||||
|
|
||||||
|
totalDijkstraTime += dijkstraSolution.getSolvingTime().toMillis();
|
||||||
|
totalAStarTime += aStarSolution.getSolvingTime().toMillis();
|
||||||
|
//totalBellmanTime += bellmanSolution.getSolvingTime().toMillis();
|
||||||
|
|
||||||
|
final int pathSize = dijkstraSolution.getPath() == null ? -1 : dijkstraSolution.getPath().getArcs().size();
|
||||||
|
System.out.println(pathSize + " "
|
||||||
|
+ dijkstraSolution.getSolvingTime().toMillis() + " "
|
||||||
|
+ aStarSolution.getSolvingTime().toMillis() + " "
|
||||||
|
//+ bellmanSolution.getSolvingTime().toMillis() + " "
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.println("Dijkstra took " + totalDijkstraTime + " ms");
|
System.out.println("Dijkstra took " + totalDijkstraTime + " ms");
|
||||||
|
@ -47,7 +61,8 @@ public class RunTimeTrial {
|
||||||
private static ArcInspector getRandomArcFilter() {
|
private static ArcInspector getRandomArcFilter() {
|
||||||
final Random rand = new Random();
|
final Random rand = new Random();
|
||||||
final List<ArcInspector> filters = ArcInspectorFactory.getAllFilters();
|
final List<ArcInspector> filters = ArcInspectorFactory.getAllFilters();
|
||||||
return filters.get(Math.abs(rand.nextInt()) % filters.size());
|
//return filters.get(Math.abs(rand.nextInt()) % filters.size());
|
||||||
|
return filters.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ShortestPathData getRandomShortestPathData(Graph graph) {
|
private static ShortestPathData getRandomShortestPathData(Graph graph) {
|
||||||
|
|
Loading…
Reference in a new issue