diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2024-03-03 12:31:03 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2024-03-03 12:40:58 +0000 |
| commit | 663627742685c1f52ec1ad92c73d3c650c3e1536 (patch) | |
| tree | 6721c421c23fb4c53f2fe5257b6c36b1a93e1ac9 /src | |
| parent | c1bfbb0444bd4bab3caa44a7a8e1979725ac2226 (diff) | |
Measure frametime
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/src/loop.c | 10 | ||||
| -rw-r--r-- | src/rendering/src/rendering.c | 4 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/core/src/loop.c b/src/core/src/loop.c index deb3768..a950a9f 100644 --- a/src/core/src/loop.c +++ b/src/core/src/loop.c @@ -301,7 +301,10 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) { //#ifdef BENCHMARK if (now - last_fps_measurement > 1.000) { - printf("\n FPS: %.1f \t ticks: %lu", (double)(ticks - last_fps_ticks) / (now - last_fps_measurement), ticks); + 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; } @@ -360,11 +363,16 @@ i32 engine_run(Platform* p, StateType initial_state, void* state_arg) { } } else { + f64 t = get_time(); render_begin(p->window); // ??? render_present(p->window); + + if (last_fps_measurement == now) { + printf("\n rendertime: %.1f", (double)(get_time() - t) * 1000.); + } } ticks++; diff --git a/src/rendering/src/rendering.c b/src/rendering/src/rendering.c index 611f997..6f34f82 100644 --- a/src/rendering/src/rendering.c +++ b/src/rendering/src/rendering.c @@ -68,6 +68,7 @@ void render_present(Window* w) { // bind index buffer + f64 t = get_time(); RenderObject* o = dc.data.model.model; vec3 pos; glm_vec3_copy(dc.data.model.pos, pos); @@ -121,6 +122,9 @@ void render_present(Window* w) { } //gl->DisableVertexAttribArray(1); gl->BindVertexArray(0); + if (i == 8) { + printf("\r obj: %.3f", (double)(get_time() - t) * 1000.); + } |
