diff options
Diffstat (limited to 'test/perf.zig')
| -rw-r--r-- | test/perf.zig | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/perf.zig b/test/perf.zig index fca4a3b0..95b55748 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -49,6 +49,10 @@ const Op = enum { /// 2 MB appended to the file through 9P, on one open, in 256 KB /// writes: linear, not a copy of the whole buffer per write. body_write, + /// 64 appends to the file through 9P, each its own open, 8 KB write and + /// close, as a shell's `>>` loop makes: each costs its own bytes, not a + /// pass over the whole body for its cursor, line index and saved hash. + body_appends, fn label(o: Op) []const u8 { return switch (o) { @@ -60,6 +64,7 @@ const Op = enum { .wheel => "wheel", .edit_char => "edit-char", .body_write => "body-2m", + .body_appends => "body-appends", }; } }; @@ -78,6 +83,20 @@ fn bodyWrite(core: *pardes.Pardes, serial: u32) void { _ = core.serveFs(.{ .tag = 4, .op = .release, .node = body, .handle = h, .opened = true }); } +const append_chunk_len = 8 * 1024; +const append_count = 64; + +fn bodyAppends(core: *pardes.Pardes, serial: u32) void { + const Node = pardes.ctlfs.Node; + const body = Node.of(serial, .body); + for (body_chunk[0..append_chunk_len], 0..) |*c, i| c.* = if (i % 64 == 63) '\n' else 'y'; + for (0..append_count) |_| { + const h = core.serveFs(.{ .tag = 1, .op = .open, .node = body, .omode = 1 }).handle; + _ = core.serveFs(.{ .tag = 2, .op = .write, .node = body, .handle = h, .data = body_chunk[0..append_chunk_len] }); + _ = core.serveFs(.{ .tag = 4, .op = .release, .node = body, .handle = h, .opened = true }); + } +} + const TermFixture = struct { name: []const u8, kb: usize, @@ -533,6 +552,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u .wheel => core.update(.{ .mouse = .{ .button = .wheel_down, .kind = .press, .col = wheel_col, .row = wheel_row } }), .edit_char => core.update(.{ .key = .{ .cp = 'x', .text = "x" } }), .body_write => bodyWrite(core, pane.serial), + .body_appends => bodyAppends(core, pane.serial), } pump(core); _ = try frame(core); @@ -540,6 +560,7 @@ fn measure(op: Op, fx: Fixture, path: []const u8, expected_bytes: usize, reps: u switch (op) { .open => 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 => 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.body.cur_row != before.row + 1) return error.DownDidNotMove, |
