summaryrefslogtreecommitdiffhomepage
path: root/bench/01-dijkstra.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-11-06 18:31:59 +0100
committerStanislaw Halik <sthalik@misaki.pl>2023-11-06 18:32:31 +0100
commit5240a5c28a5225c4c1ebd02eb97c902e10d65657 (patch)
tree54b42729ea3d9c98856968b761eae256439923f6 /bench/01-dijkstra.cpp
parented44ea64a8928d0df162a5cce932eef9bbb5ff55 (diff)
bbb
Diffstat (limited to 'bench/01-dijkstra.cpp')
-rw-r--r--bench/01-dijkstra.cpp71
1 files changed, 0 insertions, 71 deletions
diff --git a/bench/01-dijkstra.cpp b/bench/01-dijkstra.cpp
deleted file mode 100644
index 08f310d4..00000000
--- a/bench/01-dijkstra.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-#include "src/path-search.hpp"
-#include "src/path-search-result.hpp"
-#include "loader/loader.hpp"
-#include <benchmark/benchmark.h>
-#include <Corrade/Containers/Optional.h>
-#include <Magnum/Math/Functions.h>
-
-namespace floormat {
-
-namespace {
-
-auto A = astar();
-bool first_run = false;
-
-
-void Dijkstra(benchmark::State& state)
-{
- auto w = world();
-
- 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();
- constexpr auto wch = chunk_coords_{wcx, wcy, 0};
- constexpr auto wt = local_coords{wtx, wty};
- constexpr auto wpos = global_coords{wch, wt};
-
- auto& ch = w[wch];
- auto metal2 = tile_image_proto{loader.tile_atlas("metal2", {2, 2}, pass_mode::blocked), 0};
-
- for (int16_t j = wcy - 1; j <= wcy + 1; j++)
- for (int16_t i = wcx - 1; i <= wcx + 1; i++)
- {
- auto &c = w[chunk_coords_{i, j, 0}];
- for (int k : { 3, 4, 5, 6, 11, 12, 13, 14, 15, })
- {
- c[{ k, k }].wall_north() = metal2;
- c[{ k, k }].wall_west() = metal2;
- }
- }
-
- ch[{ wtx, wty }].wall_west() = metal2;
- ch[{ wtx, wty }].wall_north() = metal2;
- ch[{ wtx+1, wty }].wall_west() = metal2;
- ch[{ wtx, wty +1}].wall_north() = metal2;
-
- for (int16_t j = wcy - 1; j <= wcy + 1; j++)
- for (int16_t i = wcx - 1; i <= wcx + 1; i++)
- {
- auto& c = w[chunk_coords_{i, j, 0}];
- c.mark_passability_modified();
- c.ensure_passability();
- }
-
- 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);
- };
-
- run();
- first_run = false;
- for (auto _ : state)
- run();
-}
-
-} // namespace
-
-BENCHMARK(Dijkstra)->Unit(benchmark::kMillisecond)->ReportAggregatesOnly();
-
-} // namespace floormat