From 342c73f4f39ffd936bcd6f93d5c27492432be4e9 Mon Sep 17 00:00:00 2001 From: Jared Miller Date: Mon, 15 Dec 2025 18:40:04 -0500 Subject: [PATCH] Show FPS in benchmark log --- src/sandbox_main.zig | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/sandbox_main.zig b/src/sandbox_main.zig index 4d187f7..a0ad956 100644 --- a/src/sandbox_main.zig +++ b/src/sandbox_main.zig @@ -85,15 +85,14 @@ const BenchmarkLogger = struct { if (!crossed_threshold and !big_jump and !heartbeat_due) return; - // determine note - var note: []const u8 = ""; - if (crossed_threshold and now_above) { - note = "[!60fps]"; - } else if (crossed_threshold and !now_above) { - note = "[+60fps]"; - } else if (big_jump) { - note = "[jump]"; - } + const fps = if (frame_ms > 0) 1000.0 / frame_ms else 0; + + // determine note - show ! when below target fps + var note_buf: [16]u8 = undefined; + const note = if (now_above) + std.fmt.bufPrint(¬e_buf, "[!{d:.0}fps]", .{fps}) catch "" + else + std.fmt.bufPrint(¬e_buf, "[{d:.0}fps]", .{fps}) catch ""; var buf: [256]u8 = undefined; const line = std.fmt.bufPrint(&buf, "[{d:.1}s] entities={d} frame={d:.1}ms update={d:.1}ms render={d:.1}ms {s}\n", .{