From b5f8c6d173ccebefb6f08192873a96bcc9f86cd9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:53:14 -0300 Subject: FrameStats: the timedemos leave the binary: PARDES_FRAMES_DEMO names a text script (parseScript: ` [x] ` a line, a wheel, touch, key, keys, phase, click, rail_wheel, paste, exec or end), the fifteen compiled ones are tools/demos/*.txt, each read back step for step identical to its builder before the builders went (11,401 steps the binary no longer carries: the Debug binary's .data.rel.ro 8,566,256 to 7,944,088 bytes, an idle detached session's RSS 38.3 to 37.3 MB), and the keystroke one is test/perf.zig's own data, parsed for its tty and written beside its files for its window; a window whose script does not read does not start; a test reads every script in tools/demos Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/perf.zig | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'test/perf.zig') diff --git a/test/perf.zig b/test/perf.zig index 31a813cb..274e793f 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -1188,7 +1188,28 @@ fn liveSweep(io: std.Io) void { } } -/// The bytes a terminal sends for a step of FrameStats.keys. +/// Keystroke-to-present, a phase a gesture (FrameStats.parseScript's +/// script): --live sends its steps to the tty through a pty, and +/// --live-gui has the window run it (PARDES_FRAMES_DEMO), so the two +/// frontends are timed alike. +const keys_script = + \\1500 phase key-down + \\1500 150x30 key j + \\6000 phase key-right + \\6000 75x30 keys l h + \\10500 phase edit-char + \\10500 key i + \\10530 150x30 key x + \\15030 key escape + \\15330 phase page-down + \\15330 60x50 key page_down + \\18330 phase wheel + \\18330 150x30 wheel 1 + \\23330 phase done + \\23330 end +; + +/// The bytes a terminal sends for a step of `keys_script`. fn stepBytes(buf: *[32]u8, step: pardes.FrameStats.Step) []const u8 { return switch (step.act) { .key => |k| switch (k.cp) { @@ -1298,7 +1319,7 @@ fn liveKeysTty(l: *Live, exe: [:0]const u8) !void { var starts: [live_phases.len + 1]u64 = @splat(std.math.maxInt(u64)); const t0 = nowNs(); var buf: [32]u8 = undefined; - for (pardes.FrameStats.named("keys").?) |step| { + for (try pardes.FrameStats.parseScript(gpa, keys_script)) |step| { const due = t0 + @as(u64, step.at_ms) * std.time.ns_per_ms; while (nowNs() < due) _ = try h.pumpOnce(@intCast(@max(1, (due -| nowNs()) / std.time.ns_per_ms))); switch (step.act) { @@ -1348,7 +1369,8 @@ fn liveOpen(l: *Live, exe: [:0]const u8) !void { fn liveKeysGui(l: *Live, exe: [:0]const u8) !void { const dump_path = try l.path("gui-frames.tsv"); _ = setenv("PARDES_FRAMES", dump_path, 1); - _ = setenv("PARDES_FRAMES_DEMO", "keys", 1); + try writeFile(try l.path("keys.txt"), keys_script); + _ = setenv("PARDES_FRAMES_DEMO", try l.path("keys.txt"), 1); _ = setenv("PARDES_TEST", "1", 1); _ = setenv("PARDES_TEST_CAPTURE_DIR", try std.fmt.allocPrintSentinel(gpa, "{s}", .{l.dir}, 0), 1); _ = setenv("PARDES_TEST_COLS", try std.fmt.allocPrintSentinel(gpa, "{d}", .{screen_cols}, 0), 1); -- cgit v1.3