summaryrefslogtreecommitdiff
path: root/test/perf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-27 23:06:11 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commit95a3a1bb822e583988bfe0f312d0ef219b27a454 (patch)
tree95306e8d3f36f8af05b3ea919f6cdef1e94a028b /test/perf.zig
parentc8f0c25a854b8e169db08a84d1fdcd915a70aaa0 (diff)
downloadpardes-95a3a1bb822e583988bfe0f312d0ef219b27a454.tar.gz
pardes-95a3a1bb822e583988bfe0f312d0ef219b27a454.zip
Give a pane's body its own Text holding the cursor, selections, mode and undo
acme keeps what edits a text in its Text (dat.h:171-190) and the window holds a body and a tag of that type. The cursor, the selections, the modal state and the edit-buffer undo move off Pane into Text.zig, Pane holds them as its body, and the edit and normal-mode operations take the Text they edit. Nothing changes in behaviour; this is the step that lets the tag become a second Text. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/perf.zig')
-rw-r--r--test/perf.zig78
1 files changed, 39 insertions, 39 deletions
diff --git a/test/perf.zig b/test/perf.zig
index 6ce8f014..8eec1ed0 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -229,7 +229,7 @@ fn measureStartup(io: std.Io, reps: usize, json: bool) !void {
try std.json.Stringify.valueAlloc(gpa, result, .{})
else
try std.fmt.allocPrint(gpa, "{s}: boot {d} ns (cold {d}), first frame {d} ns, {d} allocations / {d} B, peak {d} B", .{
- result.case, result.init_median_ns, result.cold_ns, result.frame_median_ns,
+ result.case, result.init_median_ns, result.cold_ns, result.frame_median_ns,
result.allocations, result.allocated_bytes, result.peak_bytes,
});
defer gpa.free(text);
@@ -473,7 +473,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
for (0..warmup + reps) |n| {
seek(pane, fx, n);
_ = try frame(core); // settle the view at the new spot, untimed
- const before = .{ .row = pane.cur_row, .col = pane.cur_col, .scroll = pane.scroll(), .len = pane.file.?.content.len };
+ const before = .{ .row = pane.body.cur_row, .col = pane.body.cur_col, .scroll = pane.scroll(), .len = pane.file.?.content.len };
const rect = core.rects[id];
const wheel_col = rect.x + pardes.config.GUTTER;
const wheel_row = if (core.settings.tag_bottom) rect.y else rect.y + pardes.BOX_H;
@@ -492,16 +492,16 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u
const dt = nowNs() -| t0;
switch (op) {
.open => unreachable,
- .render => if (pane.cur_row != before.row or pane.cur_col != before.col or pane.file.?.content.len != before.len)
+ .render => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col or pane.file.?.content.len != before.len)
return error.RenderChangedDocument,
- .key_down => if (pane.cur_row != before.row + 1) return error.DownDidNotMove,
- .key_right => if (pane.cur_row != before.row or pane.cur_col != before.col + 1) return error.RightDidNotMove,
+ .key_down => if (pane.body.cur_row != before.row + 1) return error.DownDidNotMove,
+ .key_right => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col + 1) return error.RightDidNotMove,
.page_down => if (pane.scroll() <= before.scroll and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows)
return error.PageDidNotScroll,
.wheel => if (pane.scroll() <= before.scroll and before.scroll < @as(i32, @intCast(fx.lines)) - pane.rows)
return error.WheelDidNotScroll,
.edit_char => {
- if (pane.file.?.content.len != before.len + 1 or pane.cur_row != before.row or pane.cur_col != before.col + 1)
+ if (pane.file.?.content.len != before.len + 1 or pane.body.cur_row != before.row or pane.body.cur_col != before.col + 1)
return error.CharacterWasNotInserted;
const line = pardes.panes.File.sourceLine(pane, before.row);
if (line[@intCast(before.col)] != 'x') return error.CharacterWasNotInserted;
@@ -521,13 +521,13 @@ fn measureTerm(op: TermOp, fx: TermFixture, reps: usize) !Cell {
defer core.deinit();
const pane = core.panes[0] orelse return error.MissingTerminal;
const state = pane.terminal orelse return error.MissingTerminal;
- if (op == .key_down or op == .edit_char) pane.mode = .normal;
+ if (op == .key_down or op == .edit_char) pane.body.mode = .normal;
if (op == .edit_char) {
core.update(.{ .key = .{ .cp = 'i', .text = "i" } });
pump(core);
}
_ = try frame(core);
- const motion_rows = if (op == .key_down) (try pardes.edit.paneCursorLines(core, pane)).len else 0;
+ const motion_rows = if (op == .key_down) (try pardes.edit.paneCursorLines(core, &pane.body)).len else 0;
if (op == .key_down and motion_rows < 3) return error.EmptyTerminalFixture;
var cols = screen_cols;
@@ -535,16 +535,16 @@ fn measureTerm(op: TermOp, fx: TermFixture, reps: usize) !Cell {
for (0..warmup + reps) |n| {
if (op == .key_down) {
const span = @max(1, motion_rows * 8 / 10);
- pane.cur_row = @intCast(@min(motion_rows - 2, motion_rows / 10 + (n *% 7919) % span));
- pane.cur_col = 0;
- pane.cur_pinned = true;
- pane.sticky_col = -1;
+ pane.body.cur_row = @intCast(@min(motion_rows - 2, motion_rows / 10 + (n *% 7919) % span));
+ pane.body.cur_col = 0;
+ pane.body.cur_pinned = true;
+ pane.body.sticky_col = -1;
pane.ensureCursorVisible();
_ = try frame(core);
}
const before = .{
- .row = pane.cur_row,
- .col = pane.cur_col,
+ .row = pane.body.cur_row,
+ .col = pane.body.cur_col,
.edit_len = if (pane.ovl) |overlay| overlay.text.len else 0,
.replay_head = state.replay.head,
.replay_len = state.replay.len,
@@ -570,7 +570,7 @@ fn measureTerm(op: TermOp, fx: TermFixture, reps: usize) !Cell {
_ = try frame(core);
const dt = nowNs() -| t0;
switch (op) {
- .render => if (pane.cur_row != before.row or pane.cur_col != before.col or
+ .render => if (pane.body.cur_row != before.row or pane.body.cur_col != before.col or
state.replay.head != before.replay_head or state.replay.len != before.replay_len)
return error.RenderChangedTerminal,
.output => {
@@ -590,12 +590,12 @@ fn measureTerm(op: TermOp, fx: TermFixture, reps: usize) !Cell {
state.vt.screens.active.pages.rows != pane.rows) return error.TerminalDidNotResize,
.resize_cols => if (pane.cols == before.cols or pane.rows != before.rows or
state.vt.screens.active.pages.cols != pane.cols) return error.TerminalDidNotResize,
- .key_down => if (pane.cur_row != before.row + 1) return error.DownDidNotMove,
+ .key_down => if (pane.body.cur_row != before.row + 1) return error.DownDidNotMove,
.edit_char => {
const overlay = pane.ovl orelse return error.CharacterWasNotInserted;
- if (overlay.text.len != before.edit_len + 1 or pane.cur_row != before.row or pane.cur_col != before.col + 1)
+ if (overlay.text.len != before.edit_len + 1 or pane.body.cur_row != before.row or pane.body.cur_col != before.col + 1)
return error.CharacterWasNotInserted;
- const line = pardes.modal.lineSlice(overlay.text, @intCast(pane.cur_row - overlay.row));
+ const line = pardes.modal.lineSlice(overlay.text, @intCast(pane.body.cur_row - overlay.row));
if (before.col < 0 or before.col >= line.len or line[@intCast(before.col)] != 'x')
return error.CharacterWasNotInserted;
},
@@ -711,7 +711,7 @@ const UndoOutput = struct {
fn measureUndoOutput(core: *pardes.Pardes, counter: *Allocations, arena: *std.heap.ArenaAllocator, samples: []u64) ![3]UndoOutput {
const pane = core.panes[0].?;
const pages = &pane.terminal.?.vt.screens.active.pages;
- if (pane.ed_undo_len != 0 or pane.ed_redo_len != 0) return error.UnexpectedTerminalHistory;
+ if (pane.body.ed_undo_len != 0 or pane.body.ed_redo_len != 0) return error.UnexpectedTerminalHistory;
if (pane.ovl) |overlay| core.gpa.free(overlay.text);
pane.ovl = null;
var result: [3]UndoOutput = undefined;
@@ -722,17 +722,17 @@ fn measureUndoOutput(core: *pardes.Pardes, counter: *Allocations, arena: *std.he
const first: i32 = @intCast(@min(128, pages.total_rows - 2));
for (0..depth) |index| {
pane.ovl = .{ .row = first, .rows = 2, .text = try std.fmt.allocPrint(core.gpa, "saved edit {d}\nsecond row", .{index}) };
- pane.cur_row = first + 1;
- pane.cur_col = 1;
- pane.vsel = .{ .active = true, .row = first, .col = 0 };
+ pane.body.cur_row = first + 1;
+ pane.body.cur_col = 1;
+ pane.body.vsel = .{ .active = true, .row = first, .col = 0 };
pardes.panes.Terminal.pushUndo(core, pane);
core.gpa.free(pane.ovl.?.text);
pane.ovl = null;
- if (pane.ed_undo_len != index + 1) return error.TerminalUndoSnapshotFailed;
+ if (pane.body.ed_undo_len != index + 1) return error.TerminalUndoSnapshotFailed;
}
defer {
- for (pane.ed_undo[0..pane.ed_undo_len]) |snapshot| if (snapshot.ovl) |overlay| core.gpa.free(overlay.text);
- pane.ed_undo_len = 0;
+ for (pane.body.ed_undo[0..pane.body.ed_undo_len]) |snapshot| if (snapshot.ovl) |overlay| core.gpa.free(overlay.text);
+ pane.body.ed_undo_len = 0;
}
pardes.panes.Terminal.enterTty(core, 0);
pump(core);
@@ -767,7 +767,7 @@ fn measureUndoOutput(core: *pardes.Pardes, counter: *Allocations, arena: *std.he
if (pages.countTrackedPins() != tracked_before + 2) return error.TerminalPinsLeaked;
const expected: i32 = if (start.garbage) 0 else @intCast((pages.pointFromPin(.screen, start.*) orelse return error.TerminalAnchorLost).screen.y);
const last: i32 = if (end.garbage) 0 else @intCast((pages.pointFromPin(.screen, end.*) orelse return error.TerminalAnchorLost).screen.y);
- for (pane.ed_undo[0..pane.ed_undo_len], 0..) |snapshot, index| {
+ for (pane.body.ed_undo[0..pane.body.ed_undo_len], 0..) |snapshot, index| {
const overlay = snapshot.ovl orelse return error.TerminalUndoTextLost;
var expected_buffer: [64]u8 = undefined;
const text = try std.fmt.bufPrint(&expected_buffer, "saved edit {d}\nsecond row", .{index});
@@ -812,7 +812,7 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void
pump(core);
const pane = core.panes[0] orelse return error.MissingTerminal;
const state = pane.terminal orelse return error.MissingTerminal;
- pane.mode = .tty;
+ pane.body.mode = .tty;
pane.tty_filter = false;
var arena: std.heap.ArenaAllocator = .init(counter.allocator());
defer arena.deinit();
@@ -855,17 +855,17 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void
pump(core);
_ = try core.render(arena.allocator());
const first_modal_ns = nowNs() - modal_begin;
- if (pane.mode != .normal or !pane.cur_pinned or pane.cur_row != first_row - 1) return error.FirstModalKeyDidNotMove;
+ if (pane.body.mode != .normal or !pane.body.cur_pinned or pane.body.cur_row != first_row - 1) return error.FirstModalKeyDidNotMove;
for (modal_samples, 0..) |*sample, index| {
const down = index % 2 == 0;
- const before = pane.cur_row;
+ const before = pane.body.cur_row;
_ = arena.reset(.retain_capacity);
const begin = nowNs();
core.update(.{ .key = .{ .cp = if (down) 'j' else 'k' } });
pump(core);
_ = try core.render(arena.allocator());
sample.* = nowNs() - begin;
- if (pane.cur_row != before + @as(i32, if (down) 1 else -1)) return error.ModalKeyDidNotMove;
+ if (pane.body.cur_row != before + @as(i32, if (down) 1 else -1)) return error.ModalKeyDidNotMove;
}
core.update(.{ .key = .{ .cp = core.opts.tty_toggle, .ctrl = true } });
pump(core);
@@ -883,8 +883,8 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void
const live_after_modal = counter.live;
var overlay_median_ns: [2]u64 = undefined;
var overlay_p95_ns: [2]u64 = undefined;
- pane.mode = .normal;
- pane.cur_pinned = true;
+ pane.body.mode = .normal;
+ pane.body.cur_pinned = true;
pane.ovl = .{ .row = 0, .rows = 1, .text = try core.gpa.dupe(u8, "edited output") };
for (0..2) |phase| {
for (modal_samples, 0..) |*sample, index| {
@@ -897,8 +897,8 @@ fn measureTerminalSession(io: std.Io, mib: usize, reps: usize, json: bool) !void
pump(core);
const cursor_row = pardes.panes.Terminal.gridOffset(pane) + @as(i32, pardes.panes.Terminal.gridCursor(pane).y);
pane.ovl.?.row = if (phase == 0) 0 else cursor_row - 1;
- pane.cur_row = pane.ovl.?.row;
- pane.cur_col = 0;
+ pane.body.cur_row = pane.ovl.?.row;
+ pane.body.cur_col = 0;
const surface = try core.render(arena.allocator());
sample.* = nowNs() - begin;
try checkTerminalTail(core, surface, tail_id);
@@ -1146,11 +1146,11 @@ fn seek(pane: *pardes.Pane, fx: Fixture, n: usize) void {
const row = fx.lines / 10 + (n *% 7919) % span;
f.scroll = @min(row, fx.lines -| 1);
f.syntax_dirty = true;
- pane.cur_row = @intCast(f.scroll);
- pane.cur_col = if (fx.cols > 200) @intCast(fx.cols * 3 / 4) else 0;
- pane.cur_pinned = true;
- pane.hscroll = @max(0, pane.cur_col - 40);
- pane.sticky_col = -1;
+ pane.body.cur_row = @intCast(f.scroll);
+ pane.body.cur_col = if (fx.cols > 200) @intCast(fx.cols * 3 / 4) else 0;
+ pane.body.cur_pinned = true;
+ pane.hscroll = @max(0, pane.body.cur_col - 40);
+ pane.body.sticky_col = -1;
}
fn boot() !*pardes.Pardes {