From 76cb5e18f608370ea0c3fbc2dd2c85b06baf4c13 Mon Sep 17 00:00:00 2001 From: samstalhandske Date: Sat, 22 Nov 2025 00:09:27 +0100 Subject: [PATCH] Stopwatch for seeing different system's tick-duration. --- ecs.odin | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ecs.odin b/ecs.odin index 227c24f..a00b015 100644 --- a/ecs.odin +++ b/ecs.odin @@ -3,6 +3,7 @@ package ecs import "core:container/queue" import "core:fmt" import "core:log" +import "core:time" Entity :: struct { id: Entity_ID, @@ -297,10 +298,23 @@ create_system :: proc( } tick :: proc(world: ^World) { + sw: time.Stopwatch + for &s in &world.systems { assert(&s != nil) assert(s.tick != nil) - s.tick(world, s.state) + + time.stopwatch_reset(&sw) + time.stopwatch_start(&sw) + { + s.tick(world, s.state) + } + time.stopwatch_stop(&sw) + + // TODO: SS - Reintroduce this at some point. Really nice for debugging! :) + // system_tick_time := time.stopwatch_duration(sw) + // fmt.printfln("System '%v' took %v ms.", s.name, time.duration_milliseconds(system_tick_time)) + } world.tick += 1