diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-24 23:05:03 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-24 23:05:03 -0300 |
| commit | d2984ed50f72468b1c7304f4b354a2a5f242e2ca (patch) | |
| tree | f8bdfb2aa0f4b7f3bbcd8f05feee19b2024451ff /test/perf.zig | |
| parent | 5d091b37b4641c274900d4d02b7f1d61b5a9301f (diff) | |
| download | pardes-d2984ed50f72468b1c7304f4b354a2a5f242e2ca.tar.gz pardes-d2984ed50f72468b1c7304f4b354a2a5f242e2ca.zip | |
perf: pardes-perf --walkf measures line F's hot paths in a 2,000-line file, each a step and its frame (a Down in the registers' level unrolled, a frame with `]`'s targets painted against one at rest, a Down in the themes picker), and the painted targets look for the spec's six alone (`f p T c g d`, pick-ui SPEC §4.4: the tree objects function, test, comment; a type's, an argument's, an entry's and an element's queries no longer run on the frame): a frame with `]` painted 18.1M instructions in Debug before, 11.7M after, against 1.17M at rest (walk UI line F, the brief's measures; the ReleaseFast counts in the report)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test/perf.zig')
| -rw-r--r-- | test/perf.zig | 77 |
1 files changed, 76 insertions, 1 deletions
diff --git a/test/perf.zig b/test/perf.zig index 16066e9f..9308bbcd 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -396,6 +396,8 @@ const Options = struct { search: bool = false, /// A picker's key and frame (`measurePick`). pick: bool = false, + /// The walk UI's line F: registers, painted targets, themes (`measureWalkF`). + walkf: 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). @@ -412,7 +414,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, pick, @"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, walkf, @"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, @@ -421,6 +423,7 @@ const Options = struct { .mini => opts.mini = true, .search => opts.search = true, .pick => opts.pick = true, + .walkf => opts.walkf = true, .@"self-test" => opts.self_test = true, else => { i += 1; @@ -484,6 +487,7 @@ pub fn main(init: std.process.Init) !void { 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.walkf) return measureWalkF(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 @@ -1903,6 +1907,77 @@ fn measurePick(io: std.Io) !void { if (!std.mem.endsWith(u8, landing.file.?.path, ".zig") or std.mem.indexOf(u8, landing.file.?.path, "pickme_") == null) return error.NoPreview; } +/// `--walkf`: line F's hot paths in a 2,000-line file, each a step and +/// the frame that draws it, its instructions counted: a key in the +/// registers' level unrolled (Down, its value step read again); a frame +/// with `]`'s targets painted against one at rest; a cursor move in the +/// themes picker (the window wearing the next theme). +fn measureWalkF(io: std.Io) !void { + var random: [12]u8 = undefined; + io.random(&random); + const dir = try std.fmt.allocPrint(gpa, "/tmp/pardes-walkf-{x}", .{random}); + defer gpa.free(dir); + try std.Io.Dir.createDirAbsolute(io, dir, .default_dir); + defer std.Io.Dir.cwd().deleteTree(io, dir) catch {}; + const path = try std.fmt.allocPrint(gpa, "{s}/walkf.zig", .{dir}); + defer gpa.free(path); + var body: std.ArrayList(u8) = .empty; + defer body.deinit(gpa); + for (0..250) |i| try body.print(gpa, "/// The {d}th.\nfn f{d}(a: u32) u32 {{\n const b = a + {d};\n return b;\n}}\n\ntest \"f{d}\" {{\n}}\n", .{ i, i, i, i }); + try writeFile(path, body.items); + var counter: Instructions = try .open(); + defer counter.close(); + const core = try boot(); + defer core.deinit(); + core.settings.jumps = .walk; + pardes.look.lookAt(core, 0, path); + pump(core); + _ = filePane(core) orelse return error.OpenDidNotOpenFile; + for ("abcdefgh", 0..) |r, i| try core.registers.put(gpa, r, body.items[i * 40 ..][0..200], 0, 1, true); + try frame(core); + const Step = struct { + fn run(c: *pardes.Pardes, ev: pardes.Event, n: *Instructions, s: *Slowest) !void { + const was = n.read(); + const t0 = nowNs(); + c.update(ev); + try frame(c); + s.add(nowNs() -| t0, n.read() -| was, 0); + } + }; + const shown = struct { + fn wait(c: *pardes.Pardes) !void { + c.advance(c.clock.now_ns); + c.clock.now_ns = c.view().tag_state.due_ns; + try frame(c); + } + }; + // Registers: `"`, its level shown, unrolled; then Down over its rows. + core.update(.{ .key = .{ .cp = '"' } }); + try shown.wait(core); + core.update(.{ .key = .{ .cp = pardes.Key.down } }); + var regs: Slowest = .{}; + for (0..8) |_| try Step.run(core, .{ .key = .{ .cp = pardes.Key.down } }, &counter, ®s); + regs.report("registers Down + frame", "\"", 0); + core.update(.{ .key = .{ .cp = pardes.Key.escape } }); + // A frame at rest, then frames with `]`'s targets painted. + var rest: Slowest = .{}; + var painted: Slowest = .{}; + for (0..8) |_| try Step.run(core, .tick, &counter, &rest); + core.update(.{ .key = .{ .cp = ']' } }); + try shown.wait(core); + for (0..8) |_| try Step.run(core, .tick, &counter, &painted); + rest.report("tick + frame at rest", "", 0); + painted.report("tick + frame, ] painted", "]", 0); + core.update(.{ .key = .{ .cp = pardes.Key.escape } }); + // The themes picker: Down, the window wearing the next. + pardes.Pick.open(core, core.view().active, .themes, "", "", ""); + try frame(core); + var themes: Slowest = .{}; + for (0..8) |_| try Step.run(core, .{ .key = .{ .cp = pardes.Key.down } }, &counter, &themes); + themes.report("themes Down + frame", "", 0); + if (core.theme_preview == null) return error.NoThemePreview; +} + /// The longest of a scan's calls. const Slowest = struct { calls: usize = 0, |
