diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-04 14:16:30 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-04 14:16:30 +0100 |
commit | a85eb5f8f15cf8712246c3d765708b636603ca14 (patch) | |
tree | eb2590683702878fa2ec2ea0a513ddd2a3bf6990 /bench | |
parent | 295597008e0464f57eb52f51dc5d91ecb4e20cde (diff) |
bench/dijkstra: add some asserts while at it
Diffstat (limited to 'bench')
-rw-r--r-- | bench/dijkstra.cpp | 22 |
1 files 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(); |