summaryrefslogtreecommitdiff
path: root/test/perf.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-07 01:20:25 -0300
committerGabriel Schneider <[email protected]>2026-11-07 02:20:27 -0300
commitf2784acb88c98f33fed25dbf41f1a5af278c8e84 (patch)
tree88d2aeed5f5cad47bb6f369ea3f4d7ef54c6d64c /test/perf.zig
parent15112e516880436a589f09e6f8377166692fde37 (diff)
downloadpardes-f2784acb88c98f33fed25dbf41f1a5af278c8e84.tar.gz
pardes-f2784acb88c98f33fed25dbf41f1a5af278c8e84.zip
perf.zig: --op <label> measures one gesture alone, and the three baselines (tui and gui Debug, tui ReleaseFast) are re-recorded on an idle machine at this head, re-keyed to the harness: the old files carried the pre-rewrite's numbers, and every cell is now the rewrite's own (render 90→81 µs Debug, 77→73 ReleaseFast; edits 2.6x, body-appends 100x faster)
Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/perf.zig')
-rw-r--r--test/perf.zig17
1 files changed, 13 insertions, 4 deletions
diff --git a/test/perf.zig b/test/perf.zig
index 999f3d21..174c572a 100644
--- a/test/perf.zig
+++ b/test/perf.zig
@@ -376,6 +376,8 @@ const Options = struct {
rows: u16 = 40,
base: ?[]const u8 = null,
only: ?[]const u8 = null,
+ /// One gesture alone (its label, as the report spells it), for a profile.
+ op: ?Op = null,
creation: bool = false,
startup: bool = false,
mini: bool = false,
@@ -395,7 +397,7 @@ const Options = struct {
while (i < args.len) : (i += 1) {
const arg = args[i];
if (!std.mem.startsWith(u8, arg, "--")) return error.UnknownOption;
- const option = std.meta.stringToEnum(enum { json, creation, startup, mini, @"terminal-mib", @"self-test", reps, cols, rows, base, only, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse
+ const option = std.meta.stringToEnum(enum { json, creation, startup, mini, @"terminal-mib", @"self-test", reps, cols, rows, base, only, op, @"max-ratio", live, @"live-gui" }, arg[2..]) orelse
return error.UnknownOption;
switch (option) {
.json => opts.json = true,
@@ -413,6 +415,9 @@ const Options = struct {
.rows => opts.rows = std.fmt.parseInt(u16, value, 10) catch return error.InvalidNumber,
.base => opts.base = value,
.only => opts.only = value,
+ .op => opts.op = for (std.enums.values(Op)) |o| {
+ if (std.mem.eql(u8, value, o.label())) break o;
+ } else return error.UnknownOp,
.@"terminal-mib" => opts.terminal_mib = std.fmt.parseInt(usize, value, 10) catch return error.InvalidNumber,
.@"max-ratio" => opts.max_ratio = std.fmt.parseFloat(f64, value) catch return error.InvalidNumber,
.live => opts.live = value,
@@ -491,6 +496,7 @@ pub fn main(init: std.process.Init) !void {
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;
+ if (opts.op) |o| if (o != op) continue;
cells[oi][fi] = try measure(op, fx, paths[fi], bytes[fi], reps);
}
}
@@ -500,7 +506,7 @@ pub fn main(init: std.process.Init) !void {
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;
+ if (only != null or opts.op != null) continue;
term_cells[oi][fi] = try measureTerm(op, fx, reps);
}
}
@@ -1868,6 +1874,7 @@ fn writeJson(
for (std.enums.values(Op), 0..) |op, oi| {
for (fixtures, 0..) |fx, fi| {
if (opts.only) |name| if (!std.mem.eql(u8, name, fx.name)) continue;
+ if (opts.op) |o| if (o != op) continue;
const c = cells[oi][fi];
try out.print("{s}{{\"op\":\"{s}\",\"fixture\":\"{s}\",\"min_us\":{d},\"med_us\":{d},\"p90_us\":{d},\"max_us\":{d}}}", .{
if (first) "" else ",", op.label(), fx.name, c.min_us, c.med_us, c.p90_us, c.max_us,
@@ -1875,7 +1882,7 @@ fn writeJson(
first = false;
}
}
- if (opts.only == null) for (std.enums.values(TermOp), 0..) |op, oi| {
+ if (opts.only == null and opts.op == null) for (std.enums.values(TermOp), 0..) |op, oi| {
for (term_fixtures, 0..) |fx, fi| {
const c = term_cells[oi][fi];
try out.print("{s}{{\"op\":\"{s}\",\"fixture\":\"{s}\",\"min_us\":{d},\"med_us\":{d},\"p90_us\":{d},\"max_us\":{d}}}", .{
@@ -1991,10 +1998,12 @@ fn selfTest() !void {
&.{ "--terminal-mib", "257" }, &.{ "--terminal-mib", "1", "--cols", "31" }, &.{ "--terminal-mib", "1", "--rows", "257" },
}) |args| try testing.expectError(error.InvalidMeasurement, Options.parse(args));
for ([_][]const []const u8{
- &.{"--reps"}, &.{"--cols"}, &.{"--rows"}, &.{"--only"}, &.{"--base"}, &.{"--terminal-mib"},
+ &.{"--reps"}, &.{"--cols"}, &.{"--rows"}, &.{"--only"}, &.{"--op"}, &.{"--base"}, &.{"--terminal-mib"},
}) |args| try testing.expectError(error.MissingValue, Options.parse(args));
try testing.expectError(error.UnknownOption, Options.parse(&.{"--typo"}));
try testing.expectError(error.UnknownFixture, Options.parse(&.{ "--only", "typo" }));
+ try testing.expectError(error.UnknownOp, Options.parse(&.{ "--op", "key_down" }));
+ try testing.expectEqual(Op.key_down, (try Options.parse(&.{ "--op", "key-down" })).op.?);
for ([_][]const []const u8{
&.{ "--json", "--base", "old.json" }, &.{ "--creation", "--only", "small" },
&.{ "--creation", "--base", "old.json" }, &.{ "--self-test", "--json" },