summaryrefslogtreecommitdiff
path: root/test/perf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 21:10:48 -0300
committerGabriel Schneider <[email protected]>2026-11-24 21:10:58 -0300
commit9d7f1c626687454cd2d8431aa8f6c905efd7ce97 (patch)
tree9a2c82edc4d7faaf70119f48f101bcfeaf5b2470 /test/perf.zig
parent3621482c586b1d0d3601a1668a307918f1faea93 (diff)
downloadpardes-9d7f1c626687454cd2d8431aa8f6c905efd7ce97.tar.gz
pardes-9d7f1c626687454cd2d8431aa8f6c905efd7ce97.zip
Pick: the entry points open a picker in the tag (walk UI, pick-ui SPEC.md §14.3 phase 4, item 5 of line D): in a session whose jumps walk, from the keyboard or a click (Pick.asked: never a 9P script's, which keeps the query pane whose rows it reads back and whose `not found` it hears), Find and Grep (`SPC f f`, `SPC f g`, their words), Recent (`SPC f r`), Search's sources (`SPC b b` Panes, `SPC s s` Symbols, `SPC /` All), Panes, Jumplist (`SPC j l`) and the language server's symbols and diagnostics (`SPC l s`, `l S`, `l d`, `l D`: lsp/Ask.zig, a list picker titled by its word) unroll in the tag of the pane their Enter lands in; `Jumps new-pane` (still the default) keeps today's query pane and +Jumps, so no golden moves; `/` in a body stays today's; two fixes to the items before: the band is as tall as its second step (the acts and what they act on, the sources), and with the preview off (M-p) no frame is asked for it (Pick.busy spun every frame); test/perf.zig `--pick`: a key in a Find of 50,000 paths and its frame, the frames after it while the names are scored, a cursor move over files and the frame after it that loads the preview, instructions and time; TEST FIRST: Pick.zig "pick-ui §14.3 phase 4: SPC f f from a held pane opens in its reader and Esc removes it; from a reading pane it unrolls there; Enter lands as a step leaving the list word; n walks; a Look on the word reopens it with its cursor and marks"; core-test 0 failed; pane-test 182/184 and behaviour-test (and --replay) 274/277, process-test 5 of 146 failed: all the base's (A's tests not updated in this base: Help's +Help, window mode, a PDF's SPC; the goldens find, tagnav, builtins, leader, ttyhelp of A's report), shell-test, term-test, kitty-test pass
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/perf.zig')
-rw-r--r--test/perf.zig81
1 files changed, 80 insertions, 1 deletions
diff --git a/test/perf.zig b/test/perf.zig
index f36d64ac..16066e9f 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -394,6 +394,8 @@ const Options = struct {
mini: bool = false,
/// The scans a frame's slice bounds, a call at a time (`measureSearch`).
search: bool = false,
+ /// A picker's key and frame (`measurePick`).
+ pick: bool = false,
terminal_mib: ?usize = null,
/// The real binary's keystroke-to-present, `yes` stream and big open
/// (a tty pardes), or its keystrokes alone (a pardes-gui).
@@ -410,7 +412,7 @@ const Options = struct {
while (i < args.len) : (i += 1) {
const arg = args[i];
if (!std.mem.startsWith(u8, arg, "--")) return error.UnknownOption;
- const option = std.meta.stringToEnum(enum { json, creation, startup, mini, search, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse
+ const option = std.meta.stringToEnum(enum { json, creation, startup, mini, search, pick, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse
return error.UnknownOption;
switch (option) {
.json => opts.json = true,
@@ -418,6 +420,7 @@ const Options = struct {
.startup => opts.startup = true,
.mini => opts.mini = true,
.search => opts.search = true,
+ .pick => opts.pick = true,
.@"self-test" => opts.self_test = true,
else => {
i += 1;
@@ -480,6 +483,7 @@ pub fn main(init: std.process.Init) !void {
if (opts.terminal_mib) |mib| return measureTerminalSession(init.io, mib, reps, opts.json);
if (opts.mini) return measureMini(init.io, init.gpa, reps, opts.json);
if (opts.search) return measureSearch(init.io);
+ if (opts.pick) return measurePick(init.io);
if (opts.live) |exe| return measureLive(init.io, exe, false, reps, opts.json);
if (opts.live_gui) |exe| return measureLive(init.io, exe, true, reps, opts.json);
// The image-frame cells load the image addon by the path the build baked
@@ -1824,6 +1828,81 @@ fn measureSearch(io: std.Io) !void {
}
}
+/// `--pick`: a picker's hot paths (core/Pick.zig, walk UI line D), each
+/// a step and the frame that draws it, timed and its instructions counted
+/// (user space, this thread): a key typed into a Find of 50,000 paths and
+/// the frames after it while its names are scored; a cursor move over rows
+/// that are files, and the frame after it that loads the preview into the
+/// landing pane's body (a 2,000-line file read from the disk).
+fn measurePick(io: std.Io) !void {
+ var random: [12]u8 = undefined;
+ io.random(&random);
+ const dir = try std.fmt.allocPrint(gpa, "/tmp/pardes-pick-{x}", .{random});
+ defer gpa.free(dir);
+ try std.Io.Dir.createDirAbsolute(io, dir, .default_dir);
+ defer std.Io.Dir.cwd().deleteTree(io, dir) catch {};
+ var counter: Instructions = try .open();
+ defer counter.close();
+ var body: std.ArrayList(u8) = .empty;
+ defer body.deinit(gpa);
+ for (0..2000) |i| try body.print(gpa, " const value_{d} = compute(value_{d}, \"a line of the preview\");\n", .{ i, i -| 1 });
+ var name: [160]u8 = undefined;
+ for (0..20) |i| try writeFile(try std.fmt.bufPrint(&name, "{s}/pickme_{d}.zig", .{ dir, i }), body.items);
+ const start = try std.fmt.allocPrint(gpa, "{s}/start.zig", .{dir});
+ defer gpa.free(start);
+ try writeFile(start, "const start = 1;\n");
+ const core = try boot();
+ defer core.deinit();
+ core.settings.jumps = .walk;
+ pardes.look.lookAt(core, 0, start);
+ pump(core);
+ const id = filePane(core) orelse return error.OpenDidNotOpenFile;
+ pardes.Pick.open(core, id, .find, "", "", "");
+ const pk = pardes.Pick.live(core) orelse return error.NoPicker;
+ // The listing as the disk engine would give it: 50,000 paths, the
+ // real files among them.
+ _ = core.stream.stop();
+ pk.names.reset();
+ const dirs = [_][]const u8{ "core", "dev/gui", "dev/tui", "runtime", "test/behaviour", "addons/pdf", "zig-pkg/ghostty/src/terminal" };
+ const words = [_][]const u8{ "layout", "places", "names", "query", "stream", "surface", "replica", "tape", "kitty", "render" };
+ for (0..50_000) |i| {
+ const path = if (i % 2500 == 0) try std.fmt.bufPrint(&name, "pickme_{d}.zig", .{i / 2500}) else try std.fmt.bufPrint(&name, "{s}/module_{d}/{s}_{d}.zig", .{ dirs[i % dirs.len], i / 64 % 997, words[i * 7 % words.len], i });
+ try pk.names.add(gpa, path, 0, path.len, @TypeOf(pk.names).baseOf(path), 0);
+ }
+ pk.names.typed(gpa, "");
+ while (pk.names.busy()) pk.names.rescore(gpa);
+ try frame(core);
+ const Step = struct {
+ fn run(c: *pardes.Pardes, ev: pardes.Event, n: *Instructions, s: *Slowest, hits: usize) !void {
+ const was = n.read();
+ const t0 = nowNs();
+ c.update(ev);
+ try frame(c);
+ s.add(nowNs() -| t0, n.read() -| was, hits);
+ }
+ };
+ var keys: Slowest = .{};
+ var after: Slowest = .{};
+ for ("pickme") |ch| {
+ try Step.run(core, .{ .key = .{ .cp = ch, .text = &[_]u8{ch} } }, &counter, &keys, pk.names.hits.items.len);
+ while (pk.names.busy()) try Step.run(core, .tick, &counter, &after, pk.names.hits.items.len);
+ }
+ keys.report("pick key + frame", "pickme", pk.names.hits.items.len);
+ after.report("pick tick + frame while scoring", "pickme", pk.names.hits.items.len);
+ // The first preview, then the cursor moved and the preview after it.
+ try Step.run(core, .tick, &counter, &after, 0);
+ var moves: Slowest = .{};
+ var previews: Slowest = .{};
+ for (0..19) |_| {
+ try Step.run(core, .{ .key = .{ .cp = pardes.Key.down } }, &counter, &moves, 0);
+ try Step.run(core, .tick, &counter, &previews, 0);
+ }
+ moves.report("pick Down + frame", "pickme", pk.names.hits.items.len);
+ previews.report("pick preview tick + frame", "pickme", pk.names.hits.items.len);
+ const landing = core.panes[core.paneBySerial(pk.landing) orelse return error.NoLanding].?;
+ if (!std.mem.endsWith(u8, landing.file.?.path, ".zig") or std.mem.indexOf(u8, landing.file.?.path, "pickme_") == null) return error.NoPreview;
+}
+
/// The longest of a scan's calls.
const Slowest = struct {
calls: usize = 0,