summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 23:53:14 -0300
committerGabriel Schneider <[email protected]>2026-11-05 01:21:29 -0300
commitb5f8c6d173ccebefb6f08192873a96bcc9f86cd9 (patch)
tree895ef81f75b64e4167f3812391965b4e7fe8a8d7 /test
parentdbdd21d8ebfaaedb5675a457aa385b97450237f5 (diff)
downloadpardes-b5f8c6d173ccebefb6f08192873a96bcc9f86cd9.tar.gz
pardes-b5f8c6d173ccebefb6f08192873a96bcc9f86cd9.zip
FrameStats: the timedemos leave the binary: PARDES_FRAMES_DEMO names a text script (parseScript: `<ms> [<n>x<every>] <action>` 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 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test')
-rw-r--r--test/perf.zig28
1 files changed, 25 insertions, 3 deletions
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);