From 294ad7818adc55d85767ff7a52106deedaa4618a Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Thu, 5 Nov 2026 00:22:08 -0300 Subject: Query, Stream, Places: the benchmarks inside unit tests are deleted, as no bench step takes them without a rewrite (they reach into Query's and Stream's own helpers, busy, queryPane and TestShell, read a stress file named in the environment, and perf's gate would need baselines for a new op): "zz query timings on the 1.2 MB stress file (QUERY_TIMES=)", "zz stream timings on the stress file with a worker (QUERY_TIMES=)" and "zz grep rows timings: a Grep of about 2000 rows on the stress file, a worker (GREP_TIMES=)" go, and the big-file places test keeps its asserts without its clocks and PLACES_TIMES print; the docs' numbers stay as they are Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/Query.zig | 69 ----------------------------------------------------------- 1 file changed, 69 deletions(-) (limited to 'src/Query.zig') diff --git a/src/Query.zig b/src/Query.zig index afda600c..6a0d43bb 100644 --- a/src/Query.zig +++ b/src/Query.zig @@ -2423,75 +2423,6 @@ test "Grep: lines of the files under the owner's directory, under their file; Al try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, all, "twice")); } -test "zz query timings on the 1.2 MB stress file (QUERY_TIMES=)" { - const path_z = std.c.getenv("QUERY_TIMES") orelse return error.SkipZigTest; - const path = std.mem.span(path_z); - const io = std.testing.io; - const bytes = try std.Io.Dir.cwd().readFileAlloc(io, path, std.testing.allocator, .limited(8 << 20)); - defer std.testing.allocator.free(bytes); - const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 50 }); - defer p.deinit(); - const pane = try p.setTestFile(bytes); - p.gpa.free(pane.file.?.path); - pane.file.?.path = try p.gpa.dupe(u8, path); - var frame = std.heap.ArenaAllocator.init(std.testing.allocator); - defer frame.deinit(); - _ = try p.render(frame.allocator()); - pane.body.cur_row = 15000; - pane.ensureCursorVisible(); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - const Clock = struct { - fn step(pp: *Pardes, fr: *std.heap.ArenaAllocator, ev: pardes.Event) !u64 { - const t0 = pardes.FrameStats.nowNs(); - pp.update(ev); - _ = fr.reset(.retain_capacity); - _ = try pp.render(fr.allocator()); - return pardes.FrameStats.nowNs() - t0; - } - }; - var report: std.ArrayList(u8) = .empty; - defer report.deinit(std.testing.allocator); - var base: u64 = 0; - for (0..10) |_| base += try Clock.step(p, &frame, .{ .key = .{ .cp = 'j', .text = "j" } }); - try report.print(std.testing.allocator, "a cursor move and its frame, no search: {d} us\n", .{base / 10 / 1000}); - const t_open = try Clock.step(p, &frame, .{ .key = .{ .cp = '/', .text = "/" } }); - try report.print(std.testing.allocator, "open / {d} us\n", .{t_open / 1000}); - for ("pane.v") |c| { - const t = try Clock.step(p, &frame, .{ .key = .{ .cp = c, .text = &[_]u8{c} } }); - var ticks: usize = 0; - var worst: u64 = 0; - while (busy(p) or pane.places.busy(pane)) : (ticks += 1) { - if (ticks > 500) break; - worst = @max(worst, try Clock.step(p, &frame, .tick)); - } - const qid = queryPane(p).?; - try report.print(std.testing.allocator, "key '{c}': {d} us, then {d} ticks (worst {d} us), {d} places\n", .{ c, t / 1000, ticks, worst / 1000, p.panes[qid].?.query.?.total }); - } - // Enter: frozen; then edits in the owner with the pane open. - _ = try Clock.step(p, &frame, .{ .key = .{ .cp = Key.enter } }); - _ = try Clock.step(p, &frame, .{ .key = .{ .cp = 'i', .text = "i" } }); - var worst_edit: u64 = 0; - var sum: u64 = 0; - for (0..20) |_| { - const t = try Clock.step(p, &frame, .{ .key = .{ .cp = 'x', .text = "x" } }); - worst_edit = @max(worst_edit, t); - sum += t; - const t2 = try Clock.step(p, &frame, .tick); - worst_edit = @max(worst_edit, t2); - } - try report.print(std.testing.allocator, "edit in the owner (insert x, then a tick): mean {d} us, worst {d} us\n", .{ sum / 20 / 1000, worst_edit / 1000 }); - // The same edits with no query pane at all, for the editor's own cost. - p.update(.{ .key = .{ .cp = Key.escape } }); - exec.runBuiltin(p, .Del, queryPane(p).?, "", null); - p.update(.tick); - p.update(.{ .key = .{ .cp = 'i', .text = "i" } }); - sum = 0; - for (0..20) |_| sum += try Clock.step(p, &frame, .{ .key = .{ .cp = 'x', .text = "x" } }); - try report.print(std.testing.allocator, "the same edit, no search: mean {d} us\n", .{sum / 20 / 1000}); - std.debug.print("{s}", .{report.items}); -} - test "* seeds line 1 and keeps the keyboard; SPC b b picks a pane, SPC s s a declaration; SearchPane new leaves the last where it is" { const p = try Pardes.init(std.testing.allocator, .{ .tty_only = true, .cols = 120, .rows = 48 }); defer p.deinit(); -- cgit v1.3