Benchmark for initial Search

This commit is contained in:
glax 2024-07-25 02:28:09 +02:00
parent 02e3b1e5a3
commit 3877c87094

View File

@ -8,20 +8,37 @@ public static class Benchmark
{
public static void Run(float startLat, float startLon, float endLat, float endLon, float regionSize, string importPath, string exportPath, ILogger? logger = null)
{
for (int explorationDistance = 1000; explorationDistance <= 1400; explorationDistance += 100)
for (float speedRating = 0.7f; speedRating <= 1f; speedRating += 0.1f)
{
for (int additionalExploration = 45; additionalExploration <= 80; additionalExploration += 5)
for (float angleRating = 1f; angleRating <= 1f; angleRating += 0.1f)
{
logger?.LogInformation($"Speed:{0:0.00} Angle:{0.07f:0.00} DistanceImproved:{0:0.00} DistanceSpeed:{0:0.00} ExplorationDistance:{explorationDistance:000} Additional:{additionalExploration:000}");
string name = $"{0:0.00}${0.07f:0.00}${0:0.00}${0:0.00}${explorationDistance:000}${additionalExploration:000}";
DateTime start = DateTime.Now;
Route r = new Astar(new(0, 0.07f, 0, 0),explorationDistance).
FindPath(startLat, startLon, endLat, endLon, regionSize, true, PathMeasure.Time, additionalExploration, importPath, logger);
DateTime end = DateTime.Now;
Directory.CreateDirectory(Path.Join(exportPath, "benchmark", name));
File.WriteAllText(Path.Join(exportPath, "benchmark", name, "stats.txt"), $"{end - start:hh\\:mm\\:ss\\.fff}\n{r}");
logger?.LogInformation($"Took {end-start:hh\\:mm\\:ss\\.fff}");
Renderer.Render(r, 20000, Path.Join(exportPath, "benchmark", name, "render.png"));
for (float distanceImprovedRating = 0f; distanceImprovedRating <= 0.2f; distanceImprovedRating += 0.1f)
{
for (float distanceSpeedRating = 0f; distanceSpeedRating <= 0.2f; distanceSpeedRating += 0.1f)
{
for (int explorationDistance = 1200; explorationDistance <= 1200; explorationDistance += 100)
{
for (int additionalExploration = 65; additionalExploration <= 65; additionalExploration += 5)
{
logger?.LogInformation($"Speed:{speedRating:0.00} Angle:{angleRating:0.00} DistanceImproved:{distanceImprovedRating:0.00} DistanceSpeed:{distanceSpeedRating:0.00} ExplorationDistance:{explorationDistance:000} Additional:{additionalExploration:000}");
string name = $"{speedRating:0.00}${angleRating:0.00}${distanceImprovedRating:0.00}${distanceSpeedRating:0.00}${explorationDistance:000}${additionalExploration:000}";
DateTime start = DateTime.Now;
Route r = new Astar(new(speedRating, angleRating, distanceImprovedRating, distanceSpeedRating)).
FindPath(startLat, startLon, endLat, endLon, regionSize, true, PathMeasure.Time, additionalExploration, importPath, logger);
DateTime end = DateTime.Now;
logger?.LogInformation($"Found path in {end - start:hh\\:mm\\:ss\\.fff}");
Directory.CreateDirectory(Path.Join(exportPath, "benchmark", name));
File.WriteAllText(Path.Join(exportPath, "benchmark", name, "stats.txt"), $"{end - start:hh\\:mm\\:ss\\.fff}\n{r}");
DateTime stats = DateTime.Now;
logger?.LogInformation($"Stats took {stats - end:hh\\:mm\\:ss\\.fff}");
Renderer.Render(r, 20000, Path.Join(exportPath, "benchmark", name, "render.png"));
DateTime rendered = DateTime.Now;
logger?.LogInformation($"Rendered in {rendered - stats:hh\\:mm\\:ss\\.fff}");
logger?.LogInformation($"Total {rendered - start:hh\\:mm\\:ss\\.fff}");
}
}
}
}
}
}
}