diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Places.zig | 9 | ||||
| -rw-r--r-- | src/Query.zig | 69 | ||||
| -rw-r--r-- | src/Stream.zig | 141 |
3 files changed, 0 insertions, 219 deletions
diff --git a/src/Places.zig b/src/Places.zig index e6858537..6df0ed74 100644 --- a/src/Places.zig +++ b/src/Places.zig @@ -823,9 +823,7 @@ test "places: a big file costs a keystroke its view, the ticks find the rest, an const set = &pane.places; // The line index is the file's, made once whatever asks for it first. _ = try File.lineIndex(p.gpa, &pane.file.?); - const t0 = pardes.FrameStats.nowNs(); set.search(p, pane, .typed, 0, "needle 3", false, 0, true); - const first_ns = pardes.FrameStats.nowNs() - t0; try std.testing.expect(set.hits.items.len > 0); var ticks: usize = 0; while (set.busy(pane) and ticks < 10_000) : (ticks += 1) set.settle(p, pane, true); @@ -839,17 +837,10 @@ test "places: a big file costs a keystroke its view, the ticks find the rest, an @memcpy(new[0..at], f.content[0..at]); new[at] = 'x'; @memcpy(new[at + 1 ..], f.content[at..]); - const t1 = pardes.FrameStats.nowNs(); File.setContentSpan(p, f, new, null); - const t2 = pardes.FrameStats.nowNs(); set.settle(p, pane, false); - const edit_ns = pardes.FrameStats.nowNs() - t2; - const text_ns = t2 - t1; try std.testing.expect(set.complete() and set.shows(pane)); try std.testing.expectEqual(all, set.hits.items.len); - // PLACES_TIMES=1 says the numbers (on stderr, which fails the run). - if (std.c.getenv("PLACES_TIMES") != null) - std.debug.print("places: first key {d} us, {d} ticks, an edit {d} us (the text's own splice {d} us)\n", .{ first_ns / 1000, ticks, edit_ns / 1000, text_ns / 1000 }); } test "a lowered copy's pieces not searched yet are the same in every process: a digest and a dump take them" { 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(); diff --git a/src/Stream.zig b/src/Stream.zig index 1e6abbc5..a7a0bf53 100644 --- a/src/Stream.zig +++ b/src/Stream.zig @@ -1353,54 +1353,6 @@ test "Stream: a scroll's colours are painted ahead on a worker, so PageDown afte try testing.expect(p.stream.painted_ahead >= 5); } -test "zz stream timings on the stress file with a worker (QUERY_TIMES=<path>)" { - const path_z = std.c.getenv("QUERY_TIMES") orelse return error.SkipZigTest; - const path = std.mem.span(path_z); - const bytes = try std.Io.Dir.cwd().readFileAlloc(testing.io, path, testing.allocator, .limited(8 << 20)); - defer testing.allocator.free(bytes); - const p = try Pardes.init(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); - p.advance(1); - var shell: TestShell = .init(); - shell.attach(p); - defer { - p.stream.cancelTask(); - p.stream.cancelParse(); - shell.q.deinit(); - } - var frame = std.heap.ArenaAllocator.init(testing.allocator); - defer frame.deinit(); - pane.body.cur_row = 15000; - pane.ensureCursorVisible(); - _ = try p.render(frame.allocator()); - const t0 = now(); - for ("/pane") |c| p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); - const typed = now() - t0; - var worst_wait: u64 = 0; - while (pane.file.?.context_revision == null or pane.file.?.context_revision.? != pane.file.?.revision) { - const t1 = now(); - shell.pump(p); - p.update(.tick); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - worst_wait = @max(worst_wait, now() - t1); - testing.io.sleep(.fromMilliseconds(2), .awake) catch {}; - } - var worst_key: u64 = 0; - for (".v") |c| { - const t2 = now(); - p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - worst_key = @max(worst_key, now() - t2); - for (0..12) |_| p.update(.tick); - } - std.debug.print("stream: '/pane' typed in {d} us; the worker's parse {d} ms; worst frame while it parsed {d} us; a keystroke with grouped rows {d} us\n", .{ typed / 1000, p.stream.parse_ns / std.time.ns_per_ms, worst_wait / 1000, worst_key / 1000 }); -} - test "Stream: a Grep stops at its 2000 lines and waits; More in the query pane's tag goes on" { if (comptime !filesystem.platform_has_fs) return; var tmp = testing.tmpDir(.{}); @@ -1450,99 +1402,6 @@ test "Stream: a Grep stops at its 2000 lines and waits; More in the query pane's try testing.expect(!qp.query.?.capped); } -test "zz grep rows timings: a Grep of about 2000 rows on the stress file, a worker (GREP_TIMES=<path>)" { - const Key = pardes.Key; - const path_z = std.c.getenv("GREP_TIMES") orelse return error.SkipZigTest; - const path = std.mem.span(path_z); - const bytes = try std.Io.Dir.cwd().readFileAlloc(testing.io, path, testing.allocator, .limited(8 << 20)); - defer testing.allocator.free(bytes); - const p = try Pardes.init(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); - p.advance(1); - var shell: TestShell = .init(); - shell.attach(p); - defer { - p.stream.cancelTask(); - p.stream.cancelParse(); - p.stream.cancelPaint(); - shell.q.deinit(); - } - var frame = std.heap.ArenaAllocator.init(testing.allocator); - defer frame.deinit(); - _ = try p.render(frame.allocator()); - const Stats = struct { - fn print(name: []const u8, xs: []u64) void { - if (xs.len == 0) return; - std.mem.sort(u64, xs, {}, std.sort.asc(u64)); - std.debug.print("{s}: n {d} p50 {d} us p90 {d} us max {d} us\n", .{ name, xs.len, xs[xs.len / 2] / 1000, xs[xs.len * 9 / 10] / 1000, xs[xs.len - 1] / 1000 }); - } - }; - var keys: std.ArrayList(u64) = .empty; - defer keys.deinit(testing.allocator); - var refills: std.ArrayList(u64) = .empty; - defer refills.deinit(testing.allocator); - var idle: std.ArrayList(u64) = .empty; - defer idle.deinit(testing.allocator); - panes.Query.open(p, 0, .grep, "", true); - const qid = p.active; - const q = p.panes[qid].?.query.?; - for (0..3) |round| { - for ("pane") |c| { - const t0 = now(); - p.advance(t0); - p.update(.{ .key = .{ .cp = c, .text = &[_]u8{c} } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try keys.append(testing.allocator, now() - t0); - // the frames till the next key: the debounce, the batches, the paints - const until = now() + 400 * std.time.ns_per_ms; - while (now() < until) { - const made = q.made_gen; - const t1 = now(); - p.advance(t1); - shell.pump(p); - p.update(.tick); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try (if (q.made_gen != made) &refills else &idle).append(testing.allocator, now() - t1); - testing.io.sleep(.fromMilliseconds(2), .awake) catch {}; - } - } - // back to an empty pattern for the next round - if (round < 2) for (0..4) |_| p.update(.{ .key = .{ .cp = Key.backspace } }); - } - // Enter: the whole list frozen, 2000 rows, and the frames after it. - var after: std.ArrayList(u64) = .empty; - defer after.deinit(testing.allocator); - const t3 = now(); - p.advance(t3); - p.update(.{ .key = .{ .cp = Key.enter } }); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - const t_enter = now() - t3; - const until = now() + 1000 * std.time.ns_per_ms; - while (now() < until) { - const t1 = now(); - p.advance(t1); - shell.pump(p); - p.update(.tick); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - try after.append(testing.allocator, now() - t1); - testing.io.sleep(.fromMilliseconds(2), .awake) catch {}; - } - var coloured: usize = 0; - for (p.panes[qid].?.file.?.location_rows) |row| coloured += @intFromBool(row.kind == .match and std.mem.indexOfNone(u8, row.colors, &.{0}) != null); - std.debug.print("grep rows: {d} found ({s}), {d} rows frozen, {d} coloured; Enter (2000 rows written) {d} us\n", .{ q.found.items.len, @tagName(p.stream.used), p.panes[qid].?.file.?.location_rows.len, coloured, t_enter / 1000 }); - Stats.print("frames after Enter", after.items); - Stats.print("keystroke (update + render)", keys.items); - Stats.print("refill frame (pump + tick + render, rows remade)", refills.items); - Stats.print("other frames", idle.items); -} - test "Stream: a Grep's rows recoloured are made again, never written, and a dump of them dropped by an edit loads to its digest" { if (comptime !filesystem.platform_has_fs) return; if (!syntax.enabled or !syntax.readyApart("c.zig")) return; |
