summaryrefslogtreecommitdiffhomepage
path: root/test/dijkstra.cpp
blob: 817f944a35cd34e589a77d098e86330c11f67b71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "app.hpp"
#include "path-search.hpp"
#include <chrono>
#include <Corrade/Containers/StringView.h>

namespace floormat {

namespace {

template<typename F>
requires requires (F& fun) { fun(); }
void bench_run(StringView name, F&& fun)
{
    using namespace std::chrono;
    using clock = high_resolution_clock;
    const auto t0 = clock::now();
    fun();
    for (int i = 0; i < 1000; i++)
        fun();
    const auto tm = clock::now() - t0;
    Debug{} << "test" << name << "took" << duration_cast<milliseconds>(tm).count() << "ms.";
}

} // namespace

void test_app::test_dijkstra()
{
    auto w = world();
    auto a = astar();

    bench_run("Dijkstra", [&] {
      a.Dijkstra(w, {}, 0, {{0, 0, 0}, {}}, {{1, 1, 0}, {}},
                 1*TILE_MAX_DIM*iTILE_SIZE2.x());
    });
}

} // namespace floormat