diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/perf.zig | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/test/perf.zig b/test/perf.zig index 1387a1ac..087eea80 100644 --- a/test/perf.zig +++ b/test/perf.zig @@ -47,8 +47,13 @@ fn nowNs() u64 { /// harness pins (that one matches helix's own harness; this one wants a screen /// somebody actually works in), and fixed, because half of these numbers scale /// with the number of cells on the screen. -const screen_cols: u16 = 120; -const screen_rows: u16 = 40; +/// The viewport every measurement runs in. Overridable, because the SHAPE of the +/// screen is one of the things this table exists to hold constant while something +/// else varies - and the ESP32-P4 firmware runs a 40x12 grid, where a render costs +/// 47x what it costs here for a tenth of the cells. Profiling that needs the same +/// geometry, not a scaled guess. +var screen_cols: u16 = 120; +var screen_rows: u16 = 40; /// The four shapes a file comes in. `lines` x `cols` is the generated body; /// the point of the pair is that "big" has two different meanings and they @@ -173,6 +178,7 @@ pub fn main(init: std.process.Init) !void { var json = false; var reps: usize = 25; var base_path: ?[]const u8 = null; + var only: ?[]const u8 = null; var i: usize = 1; while (i < args.len) : (i += 1) { const a = args[i]; @@ -184,7 +190,16 @@ pub fn main(init: std.process.Init) !void { } else if (std.mem.eql(u8, a, "--base") and i + 1 < args.len) { i += 1; base_path = args[i]; - } else fatal("usage: pardes-perf [--json] [--reps N] [--base old.json]", .{}); + } else if (std.mem.eql(u8, a, "--cols") and i + 1 < args.len) { + i += 1; + screen_cols = std.fmt.parseInt(u16, args[i], 10) catch screen_cols; + } else if (std.mem.eql(u8, a, "--rows") and i + 1 < args.len) { + i += 1; + screen_rows = std.fmt.parseInt(u16, args[i], 10) catch screen_rows; + } else if (std.mem.eql(u8, a, "--only") and i + 1 < args.len) { + i += 1; + only = args[i]; + } else fatal("usage: pardes-perf [--json] [--reps N] [--base old.json] [--cols N] [--rows N] [--only NAME]", .{}); } // fixtures live in a temp dir and are rewritten every run: they are inputs @@ -206,17 +221,23 @@ pub fn main(init: std.process.Init) !void { gpa.free(text); } - var cells: [std.enums.values(Op).len][fixtures.len]Cell = undefined; + // `--only` leaves the other cells zeroed rather than reshaping the table. Its purpose is + // profiling, not reporting: under `perf record` a single 63 ms cell on the largest fixture + // swamps the samples, and the question "what does ONE keystroke on a small document spend its + // time in" cannot be answered from a profile dominated by a different one. + var cells: [std.enums.values(Op).len][fixtures.len]Cell = @splat(@splat(.{})); for (std.enums.values(Op), 0..) |op, oi| { for (fixtures, 0..) |fx, fi| { + if (only) |name| if (!std.mem.eql(u8, name, fx.name)) continue; cells[oi][fi] = try measure(op, fx, paths[fi], reps); } } term_chunk = try buildTermText(4 * 1024); - var term_cells: [std.enums.values(TermOp).len][term_fixtures.len]Cell = undefined; + var term_cells: [std.enums.values(TermOp).len][term_fixtures.len]Cell = @splat(@splat(.{})); for (std.enums.values(TermOp), 0..) |op, oi| { for (term_fixtures, 0..) |fx, fi| { + if (only != null) continue; term_cells[oi][fi] = try measureTerm(op, fx, reps); } } |
