From a85eb5f8f15cf8712246c3d765708b636603ca14 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 4 Feb 2024 14:16:30 +0100 Subject: bench/dijkstra: add some asserts while at it --- bench/dijkstra.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/bench/dijkstra.cpp b/bench/dijkstra.cpp index b0f1936d..93744258 100644 --- a/bench/dijkstra.cpp +++ b/bench/dijkstra.cpp @@ -14,7 +14,7 @@ void Dijkstra(benchmark::State& state) (void)loader.wall_atlas_list(); auto w = world(); auto A = astar(); - bool first_run = false; + static bool first_run = false; constexpr auto wcx = 1, wcy = 1, wtx = 8, wty = 8, wox = 0, woy = 0; constexpr auto max_dist = (uint32_t)(Vector2i(Math::abs(wcx)+1, Math::abs(wcy)+1)*TILE_MAX_DIM*iTILE_SIZE2).length(); @@ -50,14 +50,22 @@ void Dijkstra(benchmark::State& state) } auto run = [&] { - A.Dijkstra(w, - {{0,0,0}, {11,9}}, // from - {wpos, {wox, woy}}, // to - 0, max_dist, {16,16}, // size - first_run ? 1 : 0); + return A.Dijkstra(w, + {{0,0,0}, {11,9}}, // from + {wpos, {wox, woy}}, // to + 0, max_dist, {16,16}, // size + first_run ? 1 : 0); }; - run(); + { + auto res = run(); + fm_assert(!res.is_found()); + fm_assert(res.distance() < 128); + fm_assert(res.distance() > 8); + fm_assert(res.cost() > 1800); + fm_assert(res.cost() < 3000); + } + first_run = false; for (auto _ : state) run(); -- cgit v1.2.3