summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-02-26 17:37:12 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-02-26 18:04:43 +0100
commit0111a2f91caffc2d2b7d57c2d919c4d70f42db7f (patch)
tree4a477fbfe40cf8403588d3bfd11de97939e342e3 /src
parent06c5846c94a82cffd950cce7e9dfc753e1fc7242 (diff)
display timing info in region generator
Diffstat (limited to 'src')
-rw-r--r--src/chunk-region.cpp24
-rw-r--r--src/chunk.hpp4
2 files changed, 23 insertions, 5 deletions
diff --git a/src/chunk-region.cpp b/src/chunk-region.cpp
index c0afe9f0..fb85223b 100644
--- a/src/chunk-region.cpp
+++ b/src/chunk-region.cpp
@@ -8,6 +8,7 @@
#include <array>
#include <Corrade/Containers/GrowableArray.h>
#include <Magnum/Math/Functions.h>
+#include <Magnum/Timeline.h>
namespace floormat {
@@ -128,13 +129,17 @@ auto default_region_predicate(chunk& c) noexcept
} // namespace
-auto chunk::make_pass_region() -> pass_region
+auto chunk::make_pass_region(bool debug) -> pass_region
{
- return make_pass_region(default_region_predicate(*this));
+ return make_pass_region(default_region_predicate(*this), debug);
}
-auto chunk::make_pass_region(const pred& f) -> pass_region
+auto chunk::make_pass_region(const pred& f, bool debug) -> pass_region
{
+ Timeline timeline;
+ if (debug) [[unlikely]]
+ timeline.start();
+
pass_region ret;
auto& tmp = get_tmp();
const auto nbs = _world->neighbors(_coord);
@@ -175,6 +180,19 @@ auto chunk::make_pass_region(const pred& f) -> pass_region
}
}
+ if (debug) [[unlikely]]
+ {
+ const auto time = timeline.currentFrameTime();
+ char buf[32];
+ std::snprintf(buf, sizeof buf, "%.3f", 1e3*(double)time);
+ auto c = Vector3i(_coord);
+ auto dbg = DBG_nospace;
+ dbg << "region: generating for chunk{" << c.x() << "," << c.y();
+ if (c.z() != 0)
+ dbg << "," << c.z();
+ dbg << "} took " << buf << " ms";
+ }
+
return ret;
}
diff --git a/src/chunk.hpp b/src/chunk.hpp
index e2b812fb..266d01e5 100644
--- a/src/chunk.hpp
+++ b/src/chunk.hpp
@@ -117,8 +117,8 @@ public:
static constexpr size_t max_wall_quad_count =
TILE_COUNT*Wall::Direction_COUNT*(Wall::Group_COUNT+4);
- pass_region make_pass_region();
- pass_region make_pass_region(const Search::pred& f);
+ pass_region make_pass_region(bool debug = false);
+ pass_region make_pass_region(const Search::pred& f, bool debug = false);
private:
struct ground_stuff