summaryrefslogtreecommitdiff
path: root/test/perf.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/perf.zig')
-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);