remove timings print

This commit is contained in:
2026-02-24 00:12:04 +01:00
parent bfe8c6d572
commit 3e87bbb6a5
2 changed files with 3 additions and 64 deletions

View File

@ -5,16 +5,9 @@
#include "state.hpp"
#include "tracy.hpp"
#include <iostream>
#include <raylib.h>
#include <raymath.h>
#include <tracy/Tracy.hpp>
// #include <tracy/TracyOpenGL.hpp>
#ifdef PRINT_TIMINGS
#include <chrono>
#include <ratio>
#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<double, std::milli> physics_time_accumulator =
std::chrono::duration<double, std::milli>(0);
std::chrono::duration<double, std::milli> render_time_accumulator =
std::chrono::duration<double, std::milli>(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<float>(update_accumulator) / loop_count
<< "x per frame ("
<< static_cast<int>(timestep_accumulator / TIMESTEP)
<< "x behind)." << std::endl;
last_print_time = GetTime();
physics_time_accumulator = std::chrono::duration<double, std::milli>(0);
render_time_accumulator = std::chrono::duration<double, std::milli>(0);
loop_count = 0;
update_accumulator = 0;
}
#endif
}
CloseWindow();