summaryrefslogtreecommitdiff
path: root/src/Stream.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/Stream.zig')
-rw-r--r--src/Stream.zig141
1 files changed, 0 insertions, 141 deletions
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;