summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 21:41:08 -0300
committerGabriel Schneider <[email protected]>2026-11-24 22:04:42 -0300
commitc1e71f6734fc0f74f1e059dda3e2841e8a69d0c4 (patch)
tree46843440f072010e5d304ced8a47608afdd512a5
parent9f4109bceefbfc3e63eaf510eb7d05603e09db9c (diff)
downloadpardes-c1e71f6734fc0f74f1e059dda3e2841e8a69d0c4.tar.gz
pardes-c1e71f6734fc0f74f1e059dda3e2841e8a69d0c4.zip
pardes-perf: the walk UI's tag states as cells of their own, run only when named with --op (item 3 of A2, on line A): spc (SPC struck at rest, its level shown when its delay is up, Esc), spc-down (a Down in SPC's unrolled level, the band drawn), help-type (a character and a Backspace in Help's field, its rows filtered again each), describe (describe-key's `g d` replayed, the level and the doc under the tag), and rest-keys (`j` `k` at rest in the same loop, what they compare with: key-down's frames each draw another place of the file, these the same one); each key pumped and its frame drawn, the state checked after every repetition (TagStateLost); a full run, its JSON and its text report leave them out, and a baseline needs none of them (Op.named), so perfops' cells (78, the same as tree7's full run: checked) and its derived "terminal on all" are as before; MEASURED (ReleaseFast gui, per-op instructions, small, perfops' reps 1 vs 41): rest-keys 1,957,181 (two keys and two frames: 978,590 a key), spc 3,406,652 (two keys, three frames), spc-down 1,135,602 (one key: +16% on a rest key), help-type 2,556,990 (1,278,495 a key: +31%, Help's ~300 leaves scored again on the loop), describe 2,238,963 (1,119,482 a key: +14%); key-down (its own loop, two frames and a seek) 9,933,001
Co-Authored-By: Claude Opus 5.5 <[email protected]>
-rw-r--r--test/perf.zig105
1 files changed, 101 insertions, 4 deletions
diff --git a/test/perf.zig b/test/perf.zig
index f36d64ac..ceef0de4 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -70,6 +70,31 @@ const Op = enum {
/// the window: a kind's frame costs its window's cells, never its
/// picture (docs: architecture ยง16.1, its trigger 5% of a frame).
image_frame,
+ /// The walk UI's tag states (TagState.zig), each key pumped and the
+ /// frame that draws it: SPC struck at rest, its level shown when its
+ /// delay is up, Esc back to rest (three frames, two keys).
+ spc,
+ /// A Down in SPC's unrolled level: its cursor a row on, the band drawn.
+ spc_down,
+ /// A character typed in Help's field and a Backspace: its rows
+ /// filtered again each time (two keys).
+ help_type,
+ /// describe-key's `g d` replayed: the level and the leaf's doc under the
+ /// tag (two keys).
+ describe,
+ /// `j` and `k` at rest in the same loop (two keys, two frames): what
+ /// the tag states' keys compare with (key-down's frames each draw
+ /// another place of the file).
+ rest_keys,
+
+ /// Run only when named (`--op`): a full run, its cells and the sums a
+ /// gate takes over them (perfops' "terminal on all") are as before.
+ fn named(o: Op) bool {
+ return switch (o) {
+ .spc, .spc_down, .help_type, .describe, .rest_keys => true,
+ else => false,
+ };
+ }
fn label(o: Op) []const u8 {
return switch (o) {
@@ -88,6 +113,11 @@ const Op = enum {
.body_appends => "body-appends",
.deep_selection => "deep-sel",
.image_frame => "image-frame",
+ .spc => "spc",
+ .spc_down => "spc-down",
+ .help_type => "help-type",
+ .describe => "describe",
+ .rest_keys => "rest-keys",
};
}
};
@@ -524,6 +554,7 @@ pub fn main(init: std.process.Init) !void {
for (fixtures, 0..) |fx, fi| {
if (only) |name| if (!std.mem.eql(u8, name, fx.name)) continue;
if (opts.op) |o| if (o != op) continue;
+ if (op.named() and opts.op == null) continue;
cells[oi][fi] = try measure(op, fx, paths[fi], bytes[fi], reps);
}
}
@@ -538,7 +569,7 @@ pub fn main(init: std.process.Init) !void {
}
}
- if (opts.json) try reportJson(init.io, &cells, &term_cells, &bytes, opts) else reportText(&cells, &term_cells, &bytes, reps, opts.base, base);
+ if (opts.json) try reportJson(init.io, &cells, &term_cells, &bytes, opts) else reportText(&cells, &term_cells, &bytes, reps, opts.op, opts.base, base);
if (opts.max_ratio) |ratio| try gate(&cells, &base.?, ratio);
}
@@ -583,6 +614,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
switch (op) {
.image_frame => return measureImage(std.fs.path.dirname(path).?, samples, warmup),
.client_key_down, .client_edit_char, .client_delete_undo => return measureClient(op, path, reps),
+ .spc, .spc_down, .help_type, .describe, .rest_keys => return measureTag(op, path, reps),
else => {},
}
if (op == .open) {
@@ -637,7 +669,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
const wheel_row = rect.y + pardes.BOX_H;
const t0 = nowNs();
switch (op) {
- .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo => unreachable,
+ .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo, .spc, .spc_down, .help_type, .describe, .rest_keys => unreachable,
.render, .deep_selection => {},
.key_down => core.update(.{ .key = .{ .cp = 'j', .text = "j" } }),
.key_right => core.update(.{ .key = .{ .cp = 'l', .text = "l" } }),
@@ -651,7 +683,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
_ = try frame(core);
const dt = nowNs() -| t0;
switch (op) {
- .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo => unreachable,
+ .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo, .spc, .spc_down, .help_type, .describe, .rest_keys => unreachable,
.body_write => if (pane.file.?.content.len != before.len + 8 * body_chunk.len) return error.BodyWriteWasNotAppended,
.body_appends => if (pane.file.?.content.len != before.len + append_count * append_chunk_len) return error.BodyAppendsWereNotAppended,
.render, .deep_selection => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col or pane.file.?.content.len != before.len)
@@ -736,6 +768,68 @@ fn clientKey(a: *pardes.replica.Authority, r: *pardes.replica.Replica, ev: parde
r.settle();
}
+/// A tag state's keys on the fixture's pane, each pumped and its frame
+/// drawn, from the state the op starts in (entered untimed); the state
+/// checked after each repetition.
+fn measureTag(op: Op, path: []const u8, reps: usize) !Cell {
+ const Key = pardes.Key;
+ const warmup = 3;
+ const samples = try gpa.alloc(u64, reps);
+ defer gpa.free(samples);
+ const core = try boot();
+ defer core.deinit();
+ pardes.look.lookAt(core, 0, path);
+ pump(core);
+ const id = filePane(core) orelse return error.OpenDidNotOpenFile;
+ core.view().active = id;
+ const enter: []const Key = switch (op) {
+ .spc, .rest_keys => &.{},
+ .spc_down => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = Key.down } },
+ .help_type => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = '?', .text = "?" } },
+ .describe => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = 'h', .text = "h" }, .{ .cp = 'k', .text = "k" } },
+ else => unreachable,
+ };
+ for (enter) |k| core.update(.{ .key = k });
+ pump(core);
+ _ = try frame(core);
+ const keys: []const Key = switch (op) {
+ .spc => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = Key.escape } },
+ .spc_down => &.{.{ .cp = Key.down }},
+ .help_type => &.{ .{ .cp = 'e', .text = "e" }, .{ .cp = Key.backspace } },
+ .describe => &.{ .{ .cp = 'g', .text = "g" }, .{ .cp = 'd', .text = "d" } },
+ .rest_keys => &.{ .{ .cp = 'j', .text = "j" }, .{ .cp = 'k', .text = "k" } },
+ else => unreachable,
+ };
+ const s = &core.view().tag_state;
+ for (0..warmup + samples.len) |n| {
+ const t0 = nowNs();
+ for (keys) |k| {
+ core.update(.{ .key = k });
+ pump(core);
+ _ = try frame(core);
+ // SPC's level when its delay is up: the frame that shows it.
+ if (op == .spc and k.cp == ' ') {
+ core.advance(core.clock.now_ns);
+ core.clock.now_ns = s.due_ns;
+ if (!pardes.TagState.shown(core, core.view())) return error.LevelNotShown;
+ _ = try frame(core);
+ }
+ }
+ const dt = nowNs() -| t0;
+ const held = switch (op) {
+ .spc => s.kind == .rest and s.root == null,
+ .spc_down => s.unrolled and core.panes[id].?.band_rows > 0,
+ .help_type => s.kind == .help and s.field.len == 0 and s.nhits > 0,
+ .describe => s.kind == .describe and s.found,
+ .rest_keys => s.kind == .rest and s.root == null and core.panes[id].?.body.cur_row == 0,
+ else => unreachable,
+ };
+ if (!held) return error.TagStateLost;
+ if (n >= warmup) samples[n - warmup] = dt / 1000;
+ }
+ return summarize(samples);
+}
+
fn measureImage(dir: []const u8, samples: []u64, warmup: usize) !Cell {
const path = try std.fmt.allocPrint(gpa, "{s}/picture.ppm", .{dir});
defer gpa.free(path);
@@ -1988,6 +2082,7 @@ fn reportText(
term_cells: *const [std.enums.values(TermOp).len][term_fixtures.len]Cell,
bytes: *const [fixtures.len]usize,
reps: usize,
+ named: ?Op,
base_path: ?[]const u8,
base: ?Base,
) void {
@@ -2011,6 +2106,7 @@ fn reportText(
o("\n{s}\n", .{if (base != null) &@as([12 + fixtures.len * 20]u8, @splat('-')) else &@as([12 + fixtures.len * 13]u8, @splat('-'))});
var worst_jitter: f64 = 0;
for (std.enums.values(Op), 0..) |op, oi| {
+ if (op.named() and named != op) continue;
o("{s:<12}", .{op.label()});
for (0..fixtures.len) |fi| {
const c = cells[oi][fi];
@@ -2100,6 +2196,7 @@ fn writeJson(
for (fixtures, 0..) |fx, fi| {
if (opts.only) |name| if (!std.mem.eql(u8, name, fx.name)) continue;
if (opts.op) |o| if (o != op) continue;
+ if (op.named() and opts.op == null) continue;
const c = cells[oi][fi];
try out.print("{s}{{\"op\":\"{s}\",\"fixture\":\"{s}\",\"min_us\":{d},\"med_us\":{d},\"p90_us\":{d},\"max_us\":{d}}}", .{
if (first) "" else ",", op.label(), fx.name, c.min_us, c.med_us, c.p90_us, c.max_us,
@@ -2204,7 +2301,7 @@ fn parseBase(src: []const u8, opts: Options, bytes: *const [fixtures.len]usize)
}
for (fixtures, 0..) |fixture, fi| {
if (opts.only) |name| if (!std.mem.eql(u8, name, fixture.name)) continue;
- for (file_seen) |row| if (!row[fi]) return error.BaselineCoverage;
+ for (file_seen, std.enums.values(Op)) |row, op| if (!row[fi] and !op.named()) return error.BaselineCoverage;
}
if (opts.only == null) for (term_seen) |row| {
for (row) |seen| if (!seen) return error.BaselineCoverage;