summaryrefslogtreecommitdiff
path: root/test/perf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-24 21:10:15 -0300
committerGabriel Schneider <[email protected]>2026-11-24 21:10:17 -0300
commitb28053aede910b8714db4f27ef66e59dd96945c0 (patch)
treea0aea3ca051a21cf3378de5d587357e9208deebb /test/perf.zig
parentabe3817e8dd0af41e6b5786bdbeb631219b58c23 (diff)
downloadpardes-b28053aede910b8714db4f27ef66e59dd96945c0.tar.gz
pardes-b28053aede910b8714db4f27ef66e59dd96945c0.zip
Prompt: `/` and `?` search a file's body as they are typed (walk UI, pick-ui SPEC.md §7.3, item 2 of line E): its places found from where it began (Places.search, the view's on the key, a frame's budget a tick after), tinted, the current one stronger and selected as soon as it is found (`?`: the last before the caret, once the text between is searched), the gutter marked in the blank after each line number (`▸` the current place's line, `▪` the others'), counted `3/7 · 5 lines` (`3/⋯` while they are found; the lines counted once, at the step they are all found, a pass to the last place), ` · wrapped` past the end from where it began, `0` for no match; a pattern that is no regex keeps the last places, dimmed (Places.paint), the reason in the count; Enter lands, the pattern in `/`, and folds the pane's one search word into its trail (`/dirty/ 3/7`, Trail.setWord: the newest back step, in place of the one it had); n and N write it again in place and echo `/dirty/ 4/7 · line 112` on the message row, ` ↻` after a step round an end, `–/7` with the selection off its places, every step (Prompt.settle beside the places'); the first Esc in normal mode clears a search's tints (SPEC §10.4's first step: C's Esc order when it lands) and the word stays, dimmed (draw.zig, Trail.spanOf); Look on the word lights its places again and selects the one it was on, Exec searches again from the caret (Trail.lookStep, execStep); `*` makes the selection's pattern the search word, no prompt and no query pane; Alt-Enter keeps the places as rows: today's query pane (Query.open .text), the body as it was; `?` is helix's backward search, a new role (modal.zig, config.zig); THE FAULTS THE TESTS MET, both B's and latent until a word step was made: Trail.wordOf returned the text of a COPY of the step (a slice of its stack frame: the word drawn as garbage), now the step's own bytes; Trail.lastCur held `cur` under `n`, though keep() leaves a held pane's at `n` (a search word alone: the dump's load moved it and the digests differed), now `n`; TEST FIRST: Prompt.zig "/ searches the body as it is typed ..." and "? searches back from the caret ..."; Places' `*` test reads the echo, Query's and Stream's `/` tests keep their query pane by Alt-Enter, Query's `*` test reads the word; test/perf.zig --search measures a key in `/` and `s` on a 1 MB file; goldens fsearch, lookrange (the prompt in the tag, the word in the trail); core-test 1016/1182 (166 skipped), shell-test 1229/1232, pane-test 182/184, behaviour-test 274/277 (the failures A's, as on item 1), process-test A's six and none of mine, term-test 17/17, kitty-test 45/45
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/perf.zig')
-rw-r--r--test/perf.zig32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/perf.zig b/test/perf.zig
index f36d64ac..4ba061e1 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -1822,6 +1822,38 @@ fn measureSearch(io: std.Io) !void {
}
slow.report("fill", pattern, set.hits.items.len);
}
+
+ // A key typed into a text prompt in the tag (core/Prompt.zig) on a 1 MB
+ // file, with its frame: `/` from the middle (its places from the view on,
+ // a frame's budget a tick after), `s` over the whole text (`%`).
+ const mb: Fixture = .{ .name = "onemeg", .lines = 17_000, .cols = 60 };
+ const mb_path = try std.fmt.allocPrint(gpa, "{s}/{s}.zig", .{ dir, mb.name });
+ defer gpa.free(mb_path);
+ const mb_text = try generate(mb);
+ try writeFile(mb_path, mb_text);
+ std.debug.print("prompt keys over {d} bytes\n", .{mb_text.len});
+ gpa.free(mb_text);
+ for ([_][]const u8{ "/", "%s" }) |opener| for ([_][]const u8{ "helper", "qqq" }) |typed| {
+ const core = try boot();
+ defer core.deinit();
+ pardes.look.lookAt(core, 0, mb_path);
+ pump(core);
+ const id = filePane(core) orelse return error.OpenDidNotOpenFile;
+ const pane = core.panes[id].?;
+ seek(pane, mb, 0);
+ pane.file.?.scroll = mb.lines / 2;
+ pane.body.cur_row = @intCast(mb.lines / 2);
+ _ = try frame(core);
+ for (opener) |c| core.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ _ = try frame(core);
+ for (typed, 0..) |c, n| {
+ const was = counter.read();
+ const t0 = nowNs();
+ core.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } });
+ _ = try frame(core);
+ std.debug.print("prompt {s} \"{s}\": {d} instructions, {d} us (key and frame)\n", .{ opener, typed[0 .. n + 1], counter.read() -| was, (nowNs() -| t0) / 1000 });
+ }
+ };
}
/// The longest of a scan's calls.