diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-31 06:28:48 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-31 06:28:48 -0300 |
| commit | a479792a1ab2b593642d7f648194bfa23ce01dba (patch) | |
| tree | 96ddee7d879a9084daa07db43b0b7910b072a785 /src/FrameStats.zig | |
| parent | e179cc44fe5060c76a5b00c41e53f11209f5acd9 (diff) | |
| parent | 4c761893e5b3fdae422622cfa02104ab36633045 (diff) | |
| download | pardes-a479792a1ab2b593642d7f648194bfa23ce01dba.tar.gz pardes-a479792a1ab2b593642d7f648194bfa23ce01dba.zip | |
Merge the upstream daemon and replicated client/server refactor
Diffstat (limited to 'src/FrameStats.zig')
| -rw-r--r-- | src/FrameStats.zig | 56 |
1 files changed, 55 insertions, 1 deletions
diff --git a/src/FrameStats.zig b/src/FrameStats.zig index cabb003b..c27e74af 100644 --- a/src/FrameStats.zig +++ b/src/FrameStats.zig @@ -173,7 +173,7 @@ pub fn record(stats: *FrameStats, end_ns: u64, moving: bool, skipped: bool) void if (stats.armed and @as(u64, gap) * std.time.ns_per_us * 2 > stats.period_ns * 3) stats.jank += 1; if (@as(u64, frame.update_us + frame.render_us + frame.present_us) * std.time.ns_per_us > stats.period_ns) stats.over_budget += 1; if (skipped) stats.skipped += 1; - stats.ring[stats.count % capacity] = frame; + stats.ring[@intCast(stats.count % capacity)] = frame; stats.count += 1; stats.last_end_ns = end_ns; stats.armed = moving; @@ -269,6 +269,9 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void { } write.line(fd, &buf, "# start_ms\tupdate_us\trender_us\tpresent_us\tgap_us\tmoving\tskipped\tscroll\n", .{}); const t0 = if (all[0].len != 0) all[0][0].start_ns else 0; + // The monotonic clock is the machine's: a driver lines its own times + // up with the frames' by this. + write.line(fd, &buf, "# t0_ns {d}\n", .{t0}); // The timedemo's phases, on the frames' clock. if (stats.demo_ns != 0) if (named(stats.demo_name)) |steps| for (steps) |step| switch (step.act) { .phase => |name| write.line(fd, &buf, "# phase {s} {d:.1}\n", .{ name, @as(f64, @floatFromInt((stats.demo_ns + @as(u64, step.at_ms) * std.time.ns_per_ms) -| t0)) / std.time.ns_per_ms }), @@ -328,6 +331,7 @@ pub fn named(name: []const u8) ?[]const Step { if (std.mem.eql(u8, name, "pdf-scroll")) return &pdf_scroll; if (std.mem.eql(u8, name, "pdf-sdm")) return &pdf_sdm; if (std.mem.eql(u8, name, "one")) return &one; + if (std.mem.eql(u8, name, "keys")) return &keystrokes; if (std.mem.eql(u8, name, "jumps")) return &jumps; if (std.mem.eql(u8, name, "longlines")) return &longlines; if (std.mem.eql(u8, name, "clip-flick")) return &clip_flick; @@ -592,6 +596,56 @@ pub const pdf_sdm = blk: { break :blk out; }; +/// Keystroke-to-present, a phase a gesture, on the file the session opened: +/// test/perf.zig's --live sends these same steps to the tty through a pty +/// and --live-gui runs them here, so the two frontends are timed alike. +pub const keystrokes = blk: { + @setEvalBranchQuota(50_000); + var steps: [1024]Step = undefined; + var n: usize = 0; + var t: u32 = 1500; + const at = struct { + fn add(s: []Step, k: *usize, ms: u32, act: @FieldType(Step, "act")) void { + s[k.*] = .{ .at_ms = ms, .act = act }; + k.* += 1; + } + }; + at.add(&steps, &n, t, .{ .phase = "key-down" }); + for (0..150) |_| { + at.add(&steps, &n, t, .{ .key = .{ .cp = 'j', .text = "j" } }); + t += 30; + } + at.add(&steps, &n, t, .{ .phase = "key-right" }); + for (0..150) |i| { + at.add(&steps, &n, t, .{ .key = if (i % 2 == 0) .{ .cp = 'l', .text = "l" } else .{ .cp = 'h', .text = "h" } }); + t += 30; + } + at.add(&steps, &n, t, .{ .phase = "edit-char" }); + at.add(&steps, &n, t, .{ .key = .{ .cp = 'i', .text = "i" } }); + t += 30; + for (0..150) |_| { + at.add(&steps, &n, t, .{ .key = .{ .cp = 'x', .text = "x" } }); + t += 30; + } + at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.escape } }); + t += 300; + at.add(&steps, &n, t, .{ .phase = "page-down" }); + for (0..60) |_| { + at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.page_down } }); + t += 50; + } + at.add(&steps, &n, t, .{ .phase = "wheel" }); + for (0..150) |_| { + at.add(&steps, &n, t, .{ .wheel = 1 }); + t += 30; + } + t += 500; + at.add(&steps, &n, t, .{ .phase = "done" }); + at.add(&steps, &n, t, .end); + const out = steps[0..n].*; + break :blk out; +}; + /// `scrollSet` alone, on the file the session opened: one kind, for a /// profiler's run. pub const one = blk: { |
