diff options
Diffstat (limited to 'src/Query.zig')
| -rw-r--r-- | src/Query.zig | 69 |
1 files changed, 0 insertions, 69 deletions
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=<path>)" { - 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(); |
