From 3e87bbb6a504529ae9f5ed5173aa27cbdcfb21c0 Mon Sep 17 00:00:00 2001 From: Christoph Urlacher Date: Tue, 24 Feb 2026 00:12:04 +0100 Subject: [PATCH] remove timings print --- include/config.hpp | 1 - src/main.cpp | 66 +++------------------------------------------- 2 files changed, 3 insertions(+), 64 deletions(-) diff --git a/include/config.hpp b/include/config.hpp index 3f999eb..7440163 100644 --- a/include/config.hpp +++ b/include/config.hpp @@ -3,7 +3,6 @@ #include -#define PRINT_TIMINGS #define BARNES_HUT // Use octree BH instead of uniform grid // #define WEB // Disables multithreading diff --git a/src/main.cpp b/src/main.cpp index 6ddc04b..9c4d200 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -5,16 +5,9 @@ #include "state.hpp" #include "tracy.hpp" -#include #include #include #include -// #include - -#ifdef PRINT_TIMINGS -#include -#include -#endif // TODO: Klotski state file loading // - File should contain a single state per line, multiple lines possible @@ -41,8 +34,6 @@ auto main(int argc, char *argv[]) -> int { SetConfigFlags(FLAG_WINDOW_ALWAYS_RUN); InitWindow(INITIAL_WIDTH * 2, INITIAL_HEIGHT + MENU_HEIGHT, "MassSprings"); - // TracyGpuContext; - // Game setup OrbitCamera3D camera; Renderer renderer(camera); @@ -51,16 +42,7 @@ auto main(int argc, char *argv[]) -> int { InputHandler input(state, renderer); // Game loop -#ifdef PRINT_TIMINGS - double last_print_time = GetTime(); - std::chrono::duration physics_time_accumulator = - std::chrono::duration(0); - std::chrono::duration render_time_accumulator = - std::chrono::duration(0); - long loop_count = 0; -#endif double timestep_accumulator = 0.0; - long update_accumulator = 0; while (!WindowShouldClose()) { timestep_accumulator += GetFrameTime(); @@ -70,40 +52,22 @@ auto main(int argc, char *argv[]) -> int { state.UpdateGraph(); // Add state added after user input // Physics update -#ifdef PRINT_TIMINGS - std::chrono::high_resolution_clock::time_point ps = - std::chrono::high_resolution_clock::now(); -#endif - - // Do not try to catch up if we're falling behind. Frametimes would get - // larger, resulting in more catching up, resulting in even larger - // frametimes. - // while (timestep_accumulator > TIMESTEP) { if (timestep_accumulator > TIMESTEP) { + // Do not try to catch up if we're falling behind. Frametimes would get + // larger, resulting in more catching up, resulting in even larger + // frametimes -> death spiral. mass_springs.ClearForces(); mass_springs.CalculateSpringForces(); mass_springs.CalculateRepulsionForces(); mass_springs.VerletUpdate(TIMESTEP * SIM_SPEED); timestep_accumulator -= TIMESTEP; - update_accumulator++; } -#ifdef PRINT_TIMINGS - std::chrono::high_resolution_clock::time_point pe = - std::chrono::high_resolution_clock::now(); - physics_time_accumulator += pe - ps; -#endif - // Update the camera after the physics, so target lock is smooth camera.Update(mass_springs.GetMass(state.current_state).position); // Rendering -#ifdef PRINT_TIMINGS - std::chrono::high_resolution_clock::time_point rs = - std::chrono::high_resolution_clock::now(); -#endif - renderer.UpdateTextureSizes(); renderer.DrawMassSprings(mass_springs, state.current_state, state.starting_state, state.winning_states, @@ -115,30 +79,6 @@ auto main(int argc, char *argv[]) -> int { renderer.DrawMenu(mass_springs, state.current_preset, state.current_state, state.winning_states); renderer.DrawTextures(); - -#ifdef PRINT_TIMINGS - std::chrono::high_resolution_clock::time_point re = - std::chrono::high_resolution_clock::now(); - render_time_accumulator += re - rs; - - loop_count++; - if (GetTime() - last_print_time > 10.0) { - std::cout << " - Physics time avg: " - << physics_time_accumulator / loop_count << "." << std::endl; - std::cout << " - Render time avg: " - << render_time_accumulator / loop_count << "." << std::endl; - std::cout << " - Physics updates avg: " - << static_cast(update_accumulator) / loop_count - << "x per frame (" - << static_cast(timestep_accumulator / TIMESTEP) - << "x behind)." << std::endl; - last_print_time = GetTime(); - physics_time_accumulator = std::chrono::duration(0); - render_time_accumulator = std::chrono::duration(0); - loop_count = 0; - update_accumulator = 0; - } -#endif } CloseWindow();