summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/dijkstra.cpp26
1 files changed, 24 insertions, 2 deletions
diff --git a/test/dijkstra.cpp b/test/dijkstra.cpp
index 9b0ee1b6..7138db85 100644
--- a/test/dijkstra.cpp
+++ b/test/dijkstra.cpp
@@ -1,5 +1,6 @@
#include "app.hpp"
#include "path-search.hpp"
+#include "loader/loader.hpp"
#include <chrono>
#include <Corrade/Containers/StringView.h>
@@ -13,11 +14,16 @@ void bench_run(StringView name, F&& fun)
{
using namespace std::chrono;
using clock = high_resolution_clock;
+#if 0
for (int i = 0; i < 20; i++)
fun();
const auto t0 = clock::now();
for (int i = 0; i < 1000; i++)
fun();
+#else
+ const auto t0 = clock::now();
+ fun();
+#endif
const auto tm = clock::now() - t0;
Debug{} << "test" << name << "took" << duration_cast<milliseconds>(tm).count() << "ms.";
}
@@ -29,9 +35,25 @@ void test_app::test_dijkstra()
auto w = world();
auto a = astar();
+ auto metal2 = tile_image_proto{loader.tile_atlas("metal2", {2, 2}, pass_mode::blocked), 0};
+ auto& ch = w[chunk_coords_{0,0,0}];
+
+ ch[{4, 4}].wall_west() = metal2;
+ ch[{4, 4}].wall_north() = metal2;
+#if 1
+ ch[{8, 8}].wall_west() = metal2;
+ ch[{8, 8}].wall_north() = metal2;
+ ch[{9, 8}].wall_west() = metal2;
+ ch[{8, 7}].wall_north() = metal2;
+#endif
+ ch.mark_modified();
+
bench_run("Dijkstra", [&] {
- a.Dijkstra(w, {}, 0, {{0, 0, 0}, {0, 0}}, {{1, 1, 0}, {7, 9}},
- 1*TILE_MAX_DIM*iTILE_SIZE2.x());
+ constexpr auto max_dist = Vector2ui(2*TILE_MAX_DIM*iTILE_SIZE2).length();
+ a.Dijkstra(w,
+ {{0, 0, 0}, {0, 0}}, // from
+ {{16, 16, 0}, {7, 9}}, // to
+ 0, max_dist, {32,32}); // size
});
}