diff options
Diffstat (limited to 'test/perf.zig')
| -rw-r--r-- | test/perf.zig | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/test/perf.zig b/test/perf.zig index 00a5524a..ad873691 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -86,12 +86,16 @@ const Op = enum { /// the tag states' keys compare with (key-down's frames each draw /// another place of the file). rest_keys, + /// Ctrl-o from a list's landing onto its word (UX L'1): the list + /// reopened as it was left, its head and band drawn in the key's frame; + /// Esc back to rest and its frame (two keys, two frames). + walk_pop, /// 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, + .spc, .spc_down, .help_type, .describe, .rest_keys, .walk_pop => true, else => false, }; } @@ -118,6 +122,7 @@ const Op = enum { .help_type => "help-type", .describe => "describe", .rest_keys => "rest-keys", + .walk_pop => "walk-pop", }; } }; @@ -622,7 +627,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), + .spc, .spc_down, .help_type, .describe, .rest_keys, .walk_pop => return measureTag(op, path, reps), else => {}, } if (op == .open) { @@ -677,7 +682,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, .spc, .spc_down, .help_type, .describe, .rest_keys => unreachable, + .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo, .spc, .spc_down, .help_type, .describe, .rest_keys, .walk_pop => unreachable, .render, .deep_selection => {}, .key_down => core.update(.{ .key = .{ .cp = 'j', .text = "j" } }), .key_right => core.update(.{ .key = .{ .cp = 'l', .text = "l" } }), @@ -691,7 +696,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, .spc, .spc_down, .help_type, .describe, .rest_keys => unreachable, + .open, .image_frame, .client_key_down, .client_edit_char, .client_delete_undo, .spc, .spc_down, .help_type, .describe, .rest_keys, .walk_pop => 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) @@ -790,8 +795,17 @@ fn measureTag(op: Op, path: []const u8, reps: usize) !Cell { pump(core); const id = filePane(core) orelse return error.OpenDidNotOpenFile; core.view().active = id; + // A list of two places in the file, landed on its first (a reading + // pane's step): the list's word in its trail before the place. + if (op == .walk_pop) { + core.settings.jumps = .walk; + const rows = try std.fmt.allocPrint(gpa, "{s}:10:1 a\n{s}:20:1 b\n", .{ path, path }); + defer gpa.free(rows); + pardes.Pick.open(core, id, .list, "Refs", "", rows); + } const enter: []const Key = switch (op) { .spc, .rest_keys => &.{}, + .walk_pop => &.{.{ .cp = Key.enter }}, .spc_down => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = Key.down } }, .help_type => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = '?', .text = "?" } }, .describe => &.{ .{ .cp = ' ', .text = " " }, .{ .cp = 'h', .text = "h" }, .{ .cp = 'k', .text = "k" } }, @@ -806,8 +820,11 @@ fn measureTag(op: Op, path: []const u8, reps: usize) !Cell { .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" } }, + .walk_pop => &.{ .{ .cp = 'o', .ctrl = true }, .{ .cp = Key.escape } }, else => unreachable, }; + const landed = core.panes[id].?.trail.cur; + if (op == .walk_pop and (landed == 0 or core.panes[id].?.trail.steps[landed - 1] != .list)) return error.ListDidNotLand; const s = &core.view().tag_state; for (0..warmup + samples.len) |n| { const t0 = nowNs(); @@ -822,6 +839,8 @@ fn measureTag(op: Op, path: []const u8, reps: usize) !Cell { if (!pardes.TagState.shown(core, core.view())) return error.LevelNotShown; _ = try frame(core); } + // The list reopened by the key itself, drawn in its frame. + if (op == .walk_pop and k.ctrl and pardes.Pick.live(core) == null) return error.ListNotReopened; } const dt = nowNs() -| t0; const held = switch (op) { @@ -830,6 +849,7 @@ fn measureTag(op: Op, path: []const u8, reps: usize) !Cell { .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, + .walk_pop => s.kind == .rest and core.panes[id].?.trail.cur == landed and core.panes[id].?.body.cur_row == 9, else => unreachable, }; if (!held) return error.TagStateLost; @@ -1010,7 +1030,7 @@ fn checkTerminalTail(core: *pardes.Pardes, surface: *pardes.Surface, batch: usiz // The program's green (SGR 32) as the pane draws it with its filter off // (measureTerminalSession turns it off): the theme's own colour 2. std.debug.assert(!pane.tty_filter); - const green = pardes.ansi.inkOf(core.theme()).palColor(2); + const green = pardes.ansi.inkOf(core).palColor(2); for (expected, 0..) |byte, col| { const cell = surface.at(x + @as(u16, @intCast(col)), y); if (!std.mem.eql(u8, cell.grapheme(), &.{byte})) return error.LatestTerminalTailMissing; |
