From 0b09ee33c25e8ae8f1a7aa6b05e9453a82c65689 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Thu, 29 Feb 2024 00:39:41 +0100 Subject: always collect timing info on pathfinding/raycasting --- src/chunk-region.cpp | 10 ++++------ src/chunk-region.hpp | 1 + src/raycast.cpp | 21 +++++++++++++++------ src/raycast.hpp | 1 + 4 files changed, 21 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/chunk-region.cpp b/src/chunk-region.cpp index 4bb2be7b..62fee2c4 100644 --- a/src/chunk-region.cpp +++ b/src/chunk-region.cpp @@ -139,8 +139,7 @@ auto chunk::make_pass_region(bool debug) -> pass_region auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region { Timeline timeline; - if (debug) [[unlikely]] - timeline.start(); + timeline.start(); pass_region ret; auto& tmp = get_tmp(); @@ -184,11 +183,10 @@ auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region do_pixel.operator()(p); } + ret.time = timeline.currentFrameTime(); + if (debug) [[unlikely]] - { - const auto time = timeline.currentFrameTime(); - DBG_nospace << "region: generating for " << _coord << " took " << fraction(1e3f*time, 3) << " ms"; - } + DBG_nospace << "region: generating for " << _coord << " took " << fraction(1e3f*ret.time, 3) << " ms"; return ret; } diff --git a/src/chunk-region.hpp b/src/chunk-region.hpp index a7281c50..df2149bc 100644 --- a/src/chunk-region.hpp +++ b/src/chunk-region.hpp @@ -8,6 +8,7 @@ namespace floormat { struct chunk::pass_region { std::bitset bits; + float time = 0; }; } // namespace floormat diff --git a/src/raycast.cpp b/src/raycast.cpp index 603b7606..bfc41296 100644 --- a/src/raycast.cpp +++ b/src/raycast.cpp @@ -6,10 +6,11 @@ #include "RTree-search.hpp" #include #include -#include -#include -#include -#include +#include +#include +#include +#include +#include namespace floormat::rc { @@ -310,12 +311,20 @@ raycast_result_s do_raycasting(std::conditional_t(nullptr, w, from, to, self); + Timeline timeline; + timeline.start(); + auto ret = do_raycasting(nullptr, w, from, to, self); + ret.time = timeline.currentFrameDuration(); + return ret; } raycast_result_s raycast_with_diag(raycast_diag_s& diag, world& w, point from, point to, object_id self) { - return do_raycasting(diag, w, from, to, self); + Timeline timeline; + timeline.start(); + auto ret = do_raycasting(diag, w, from, to, self); + ret.time = timeline.currentFrameDuration(); + return ret; } } // namespace floormat::rc diff --git a/src/raycast.hpp b/src/raycast.hpp index 3871c42f..6463a143 100644 --- a/src/raycast.hpp +++ b/src/raycast.hpp @@ -17,6 +17,7 @@ struct raycast_result_s { point from, to, collision; collision_data collider; + float time = 0; bool has_result : 1 = false, success : 1 = false; }; -- cgit v1.2.3