diff options
| -rw-r--r-- | src/Tables.zig | 87 | ||||
| -rw-r--r-- | src/fs.zig | 8 |
2 files changed, 0 insertions, 95 deletions
diff --git a/src/Tables.zig b/src/Tables.zig index 552d19d6..7baffdf9 100644 --- a/src/Tables.zig +++ b/src/Tables.zig @@ -1088,90 +1088,3 @@ test "tables: a table wider than a wrapping pane is shown as its source, laid ou try testing.expect(!pane.body_wrapped); try testing.expect(File.rowTable(pane, 2) != null); } - -test "zz tables timings on a big markdown file (TABLES_TIMES=<path>)" { - const path_z = std.c.getenv("TABLES_TIMES") orelse return error.SkipZigTest; - const path = std.mem.span(path_z); - const io = testing.io; - const bytes = try std.Io.Dir.cwd().readFileAlloc(io, path, testing.allocator, .limited(16 << 20)); - defer testing.allocator.free(bytes); - const now = pardes.FrameStats.nowNs; - var report: std.ArrayList(u8) = .empty; - defer report.deinit(testing.allocator); - { - var t: Tables = .{}; - defer t.deinit(testing.allocator); - var worst: u64 = 0; - var sum: u64 = 0; - for (0..5) |_| { - const t0 = now(); - try t.scan(testing.allocator, bytes); - const d = now() - t0; - sum += d; - worst = @max(worst, d); - } - try report.print(testing.allocator, "scan of {d} bytes: {d} tables, mean {d} us, worst {d} us\n", .{ bytes.len, t.list.items.len, sum / 5 / 1000, worst / 1000 }); - } - // The same text as markdown and as plain text: what the tables cost a - // frame and an edit. - for ([_][]const u8{ "/stress.md", "/stress.txt" }) |name| { - const p = try Pardes.init(testing.allocator, .{ .tty_only = true, .cols = 160, .rows = 50 }); - defer p.deinit(); - var frame = std.heap.ArenaAllocator.init(testing.allocator); - defer frame.deinit(); - const pane = try p.setTestFile(bytes); - p.gpa.free(pane.file.?.path); - pane.file.?.path = try p.gpa.dupe(u8, name); - { - var t0 = now(); - _ = try p.render(frame.allocator()); - const first = now() - t0; - var frames: usize = 1; - var worst: u64 = first; - t0 = now(); - while (pane.file.?.tables.busy()) : (frames += 1) { - const t1 = now(); - _ = frame.reset(.retain_capacity); - _ = try p.render(frame.allocator()); - worst = @max(worst, now() - t1); - } - try report.print(testing.allocator, "{s}: the first frame {d} us; the tables read in {d} frames, the worst {d} us\n", .{ name, first / 1000, frames, worst / 1000 }); - } - // Into the middle of a table half way down. - var line: usize = File.nlines(p.gpa, &pane.file.?) / 2; - while (!std.mem.startsWith(u8, File.sourceLine(pane, @intCast(line)), "| ") or - std.mem.indexOf(u8, File.sourceLine(pane, @intCast(line)), "col") != null) line += 1; - pane.body.cur_row = @intCast(line + 2); - pane.body.cur_col = 2; - 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 sum: u64 = 0; - var worst: u64 = 0; - for (0..10) |_| { - const d = try Clock.step(p, &frame, .{ .key = .{ .cp = 'j', .text = "j" } }); - sum += d; - worst = @max(worst, d); - } - try report.print(testing.allocator, "{s}: j and its frame: mean {d} us, worst {d} us\n", .{ name, sum / 10 / 1000, worst / 1000 }); - _ = try Clock.step(p, &frame, .{ .key = .{ .cp = 'i', .text = "i" } }); - sum = 0; - worst = 0; - for (0..10) |_| { - const d = try Clock.step(p, &frame, .{ .key = .{ .cp = 'x', .text = "x" } }); - sum += d; - worst = @max(worst, d); - } - try report.print(testing.allocator, "{s}: a letter typed in a cell and its frame: mean {d} us, worst {d} us\n", .{ name, sum / 10 / 1000, worst / 1000 }); - } - std.debug.print("\n{s}", .{report.items}); -} @@ -1102,19 +1102,11 @@ pub const platform_has_fs = !pardes.isolated and switch (pardes.platform) { .web, .esp32p4 => false, }; -const find_max_hits = 512; - -const find_max_depth = 16; - pub const find_skip = [_][]const u8{ ".git", ".jj", "target", "node_modules", ".venv", "__pycache__", ".zig-cache", "zig-out", }; -// Find and Grep walk on the disk engine's worker now (Stream.zig); what is -// left here is what their notes and skips were. -const grep_max_files = 20_000; - fn isDir(path: [*:0]const u8) bool { const fd = libc.open(path, .{ .ACCMODE = .RDONLY, .DIRECTORY = true, .CLOEXEC = true }); if (fd < 0) return false; |
