From df565b90c77608548de73d179c0982cd8fd74499 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Fri, 6 Nov 2026 05:19:39 -0300 Subject: kinds #10, image-frame: the medium perf set gains a frame with a 640x400 picture's pane (the image addon's) alone in the window; 163 us in Debug against render's 89 (the Debug paint-purity hash is over the kind's memory, so there it costs the picture's bytes: 1478 us at 2560x1600), 46 us in ReleaseFast against render's 81, of which the kind's clear and scan of its 4,366 cells are 2.2 us (2.7% of a text frame, under §16.1's 5%); test/perf-baseline-tui-debug.json and -gui-debug.json re-keyed to the harness and given the cell MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/perf.zig | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) (limited to 'test/perf.zig') diff --git a/test/perf.zig b/test/perf.zig index fbe6fa49..999f3d21 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -59,6 +59,10 @@ const Op = enum { /// shown are measured, so it costs what a selection at the line's /// start does (4.5 s a frame at 5 MB before). deep_selection, + /// A frame with a 640x400 picture's pane (the image addon's) alone in + /// the window: a kind's frame costs its window's cells, never its + /// picture (docs: architecture §16.1, its trigger 5% of a frame). + image_frame, fn label(o: Op) []const u8 { return switch (o) { @@ -73,6 +77,7 @@ const Op = enum { .body_write => "body-2m", .body_appends => "body-appends", .deep_selection => "deep-sel", + .image_frame => "image-frame", }; } }; @@ -542,6 +547,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u const samples = try gpa.alloc(u64, reps); defer gpa.free(samples); + if (op == .image_frame) return measureImage(std.fs.path.dirname(path).?, samples, warmup); if (op == .open) { for (0..warmup + reps) |n| { const core = try boot(); @@ -594,7 +600,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 => unreachable, + .open, .image_frame => unreachable, .render, .deep_selection => {}, .key_down => core.update(.{ .key = .{ .cp = 'j', .text = "j" } }), .key_right => core.update(.{ .key = .{ .cp = 'l', .text = "l" } }), @@ -608,7 +614,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 => unreachable, + .open, .image_frame => 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) @@ -636,6 +642,38 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u return summarize(samples); } +fn measureImage(dir: []const u8, samples: []u64, warmup: usize) !Cell { + const path = try std.fmt.allocPrint(gpa, "{s}/picture.ppm", .{dir}); + defer gpa.free(path); + const header = "P6\n640 400\n255\n"; + const ppm = try gpa.alloc(u8, header.len + 640 * 400 * 3); + defer gpa.free(ppm); + @memcpy(ppm[0..header.len], header); + for (ppm[header.len..], 0..) |*b, i| b.* = @truncate(i / 7); + try writeFile(path, ppm); + const core = try boot(); + defer core.deinit(); + pardes.Addon.perform(core, .load, 0, @import("perf_options").image_addon); + pardes.look.lookAt(core, 0, path); + // Its decode is a job a host runs: here, at once. + while (core.nextEffect()) |e| if (e == .job) core.perform(e); + // The picture's pane alone in the window. + for (core.panes, 0..) |slot, id| if (slot) |pane| if (pane.addon == null) { + _ = core.executeBuiltinLine(id, "Del"); + pump(core); + }; + _ = try frame(core); + const shown = core.surface.placements.items; + if (shown.len != 1 or shown[0].raster.w != 640 or shown[0].dst.w + 4 < screen_cols) return error.ImageNotShown; + for (0..warmup + samples.len) |n| { + const t0 = nowNs(); + _ = try frame(core); + const dt = nowNs() -| t0; + if (n >= warmup) samples[n - warmup] = dt / 1000; + } + return summarize(samples); +} + fn measureTerm(op: TermOp, fx: TermFixture, reps: usize) !Cell { const warmup = 3; const samples = try gpa.alloc(u64, reps); -- cgit v1.3