From b5f8c6d173ccebefb6f08192873a96bcc9f86cd9 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 23:53:14 -0300 Subject: FrameStats: the timedemos leave the binary: PARDES_FRAMES_DEMO names a text script (parseScript: ` [x] ` a line, a wheel, touch, key, keys, phase, click, rail_wheel, paste, exec or end), the fifteen compiled ones are tools/demos/*.txt, each read back step for step identical to its builder before the builders went (11,401 steps the binary no longer carries: the Debug binary's .data.rel.ro 8,566,256 to 7,944,088 bytes, an idle detached session's RSS 38.3 to 37.3 MB), and the keystroke one is test/perf.zig's own data, parsed for its tty and written beside its files for its window; a window whose script does not read does not start; a test reads every script in tools/demos Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- src/FrameStats.zig | 846 ++++++++--------------------------------------------- src/gui/gui.zig | 10 +- 2 files changed, 120 insertions(+), 736 deletions(-) (limited to 'src') diff --git a/src/FrameStats.zig b/src/FrameStats.zig index 33ffd300..fb882d69 100644 --- a/src/FrameStats.zig +++ b/src/FrameStats.zig @@ -16,10 +16,11 @@ //! glyph rasterizing) and the view it showed, so a spike is attributed and //! a scroll's throughput is counted in rows actually presented. //! -//! `PARDES_FRAMES_DEMO=scroll` (or `stress`) runs a timed script of scroll -//! inputs (`named`) in a pixel shell (the GUI feeds them through its own -//! wheel and key paths) and then ends the session: a timedemo, so two -//! builds are compared on the same motion, on a real display. +//! `PARDES_FRAMES_DEMO=` runs a timed script of inputs (`parseScript`; +//! the ones the notes measured with are in tools/demos/) in a pixel shell +//! (the GUI feeds them through its own wheel and key paths) and then ends +//! the session: a timedemo, so two builds are compared on the same motion, +//! on a real display. const std = @import("std"); const pardes = @import("pardes.zig"); const animation = @import("animation.zig"); @@ -100,9 +101,9 @@ shaped: u16 = 0, rastered: u16 = 0, bytes: u32 = 0, landed: u16 = 0, -/// When the timedemo started, monotonic ns (0: none ran), and which. +/// When the timedemo started, monotonic ns (0: none ran), and its steps. demo_ns: u64 = 0, -demo_name: []const u8 = "", +demo: []const Step = &.{}, /// The frame being timed: its marks, the monotonic clock's ns. mark_start: u64 = 0, mark_update: u64 = 0, @@ -272,7 +273,7 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void { // 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) { + for (stats.demo) |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 }), else => {}, }; @@ -289,7 +290,7 @@ pub fn dump(stats: *const FrameStats, path: [:0]const u8) void { }; } -/// One input of the scroll timedemo, `at_ms` after the first frame. +/// One input of a timedemo, `at_ms` after the first frame. pub const Step = struct { at_ms: u32, act: union(enum) { @@ -316,732 +317,97 @@ pub const Step = struct { }, }; -/// Every kind of scroll a user makes, on a long file from its top: single -/// notches, a fast spin of the wheel both ways (notches 8 ms apart, two a -/// frame: each retargets the one before), half pages, pages, the far jumps -/// to the end (ge) and back (gg), half pages faster than they settle, and the cursor -/// moving a line, a word and, in insert mode, a column at a time. -/// The timedemo PARDES_FRAMES_DEMO names, if any. -pub fn named(name: []const u8) ?[]const Step { - if (std.mem.eql(u8, name, "scroll")) return &demo; - if (std.mem.eql(u8, name, "stress")) return &stress; - if (std.mem.eql(u8, name, "kinds")) return &kinds; - if (std.mem.eql(u8, name, "panes")) return &panes; - 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; - if (std.mem.eql(u8, name, "clip-far")) return &clip_far; - if (std.mem.eql(u8, name, "clip-cursor")) return &clip_cursor; - if (std.mem.eql(u8, name, "clip-query")) return &clip_query; - if (std.mem.eql(u8, name, "clip-terminal")) return &clip_terminal; - if (std.mem.eql(u8, name, "clip-pages")) return &clip_pages; - return null; -} - -pub const demo = blk: { - @setEvalBranchQuota(20_000); - var steps: [128]Step = undefined; - var n: usize = 0; - var t: u32 = 1500; - steps[n] = .{ .at_ms = t, .act = .{ .phase = "notches" } }; - n += 1; - for (0..10) |_| { - steps[n] = .{ .at_ms = t, .act = .{ .wheel = 1 } }; - n += 1; - t += 150; - } - t += 400; - steps[n] = .{ .at_ms = t, .act = .{ .phase = "spin" } }; - n += 1; - for ([_]i8{ 1, -1 }) |dir| { - for (0..24) |_| { - steps[n] = .{ .at_ms = t, .act = .{ .wheel = dir } }; - n += 1; - t += 8; - } - t += 800; - } - const ctrl = struct { - fn key(cp: u21) pardes.Key { - return .{ .cp = cp, .ctrl = true }; +/// A timedemo's script, the file PARDES_FRAMES_DEMO names (tools/demos/): an +/// input a line, ` []` at `ms` after the first frame, or +/// ` x []` for n of them `every` ms apart; a +/// line that starts with `#` says what the script is. The actions: `wheel +/// ` (down positive), `touch `, `key `, `keys ...` +/// (its keys in turn, each `every` ms after the one before, n times over), +/// `phase `, `click