diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-28 23:46:23 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-02-28 23:46:23 +0100 |
commit | 3a4fb937342c5bc57fce0f48b81b81ed06b32bf9 (patch) | |
tree | b84362d468e8f1fe346d4528901b09c8af6a1b7d /editor/tests | |
parent | 396513259863963bf14453bbbf41dfddbc31ef7d (diff) |
editor/tests: show timing info in the ui
Diffstat (limited to 'editor/tests')
-rw-r--r-- | editor/tests/raycast-test.cpp | 10 | ||||
-rw-r--r-- | editor/tests/region-test.cpp | 9 |
2 files changed, 19 insertions, 0 deletions
diff --git a/editor/tests/raycast-test.cpp b/editor/tests/raycast-test.cpp index 1b06c0f3..76fdde8b 100644 --- a/editor/tests/raycast-test.cpp +++ b/editor/tests/raycast-test.cpp @@ -10,6 +10,7 @@ #include <array> #include <vector> #include <mg/Color.h> +#include <mg/Timeline.h> namespace floormat::tests { @@ -56,6 +57,7 @@ struct raycast_test final : base_test raycast_result_s result; pending_s pending; raycast_diag_s diag; + float time = 0; ~raycast_test() noexcept override; @@ -68,6 +70,7 @@ struct raycast_test final : base_test { if (e.button == mouse_button_left && is_down) { + time = 0; auto& M = a.main(); auto& w = M.world(); if (auto pt_ = a.cursor_state().point()) @@ -245,6 +248,10 @@ struct raycast_test final : base_test do_column("path-len"); std::snprintf(buf, std::size(buf), "%zu", diag.path.size()); text(buf); + + do_column("time"); + std::snprintf(buf, std::size(buf), "%.3f ms", (double)(1000 * time)); + text(buf); } } @@ -263,7 +270,10 @@ struct raycast_test final : base_test fm_warn("raycast: wrong Z value"); return; } + Timeline timeline; + timeline.start(); result = raycast_with_diag(diag, a.main().world(), pending.from, pending.to, pending.self); + time = timeline.currentFrameDuration(); } } }; diff --git a/editor/tests/region-test.cpp b/editor/tests/region-test.cpp index e17cd130..895604fb 100644 --- a/editor/tests/region-test.cpp +++ b/editor/tests/region-test.cpp @@ -8,6 +8,7 @@ #include "floormat/main.hpp" #include <bitset> #include <mg/Vector2.h> +#include <mg/Timeline.h> namespace floormat::tests { @@ -30,6 +31,7 @@ struct result_s { std::bitset<chunk_bits> is_passable; chunk_coords_ c; + float time = 0; bool exists : 1 = false; }; @@ -113,6 +115,10 @@ void region_test::draw_ui(app&, float) std::snprintf(buf, sizeof buf, "%zu", result.is_passable.size() - result.is_passable.count()); //{ auto b = push_style_color(ImGuiCol_Text, 0xffff00ff_rgbaf); text(buf); } text(buf); + + do_column("time"); + std::snprintf(buf, sizeof buf, "%.1f ms", (double)(1000 * result.time)); + text(buf); } } @@ -152,9 +158,12 @@ void region_test::do_region_extraction(world& w, chunk_coords_ coord) { if (auto* c = w.at(coord)) { + Timeline timeline; + timeline.start(); result = { .is_passable = c->make_pass_region(true).bits, .c = coord, + .time = timeline.currentFrameDuration(), .exists = true, }; } |