summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronelin <oscar@nelin.dk>2025-03-12 11:37:03 +0000
committeronelin <oscar@nelin.dk>2025-03-12 11:38:29 +0000
commitd51f8c276a67878c8fa04ae50bc3de02e188e708 (patch)
treeb108d7983f21027da17e4f9c1a8d6647c816c8c9
parentb8a11fa6c6530cb5ed8e865adf6359e526ead28f (diff)
Move stat measures & printing
-rw-r--r--src/core/src/loop.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/src/core/src/loop.c b/src/core/src/loop.c
index 774ac86..d80e350 100644
--- a/src/core/src/loop.c
+++ b/src/core/src/loop.c
@@ -315,17 +315,6 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
const f64 dt = now - time;
time = now;
-//#ifdef BENCHMARK
- if (now - last_fps_measurement > 1.000) {
- printf("\n FPS: %.1f \t ticks: %lu \t frametime: %.1f"
- , (double)(ticks - last_fps_ticks) / (now - last_fps_measurement)
- , ticks
- , dt * 1000.f);
- last_fps_measurement = now;
- last_fps_ticks = ticks;
- }
-//#endif
-
glfwPollEvents();
/* Events */
// if (p->mouse_lclick) {
@@ -385,6 +374,27 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) {
render_present(p->window);
const f64 rendertime_dt = get_time() - rendertime_begin;
+
+ /* Print stats */
+ const f64 now = get_time();
+ const f64 dt_measurement = now - last_fps_measurement;
+ /* only make measurements once a second */
+ if (dt_measurement > 1000.0) {
+
+ printf(" FPS: %.1f"
+ "\tticks: %lu"
+ "\tframetime: %.1fms"
+ "\trendertime: %.2fms"
+ "\n"
+ , ((f64)(ticks - last_fps_ticks)) / (dt_measurement / 1000.0)
+ , ticks
+ , dt
+ , rendertime_dt
+ );
+
+ last_fps_measurement = now;
+ last_fps_ticks = ticks;
+ }
}