summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/FrameStats.zig78
-rw-r--r--src/pdf_view.zig7
2 files changed, 83 insertions, 2 deletions
diff --git a/src/FrameStats.zig b/src/FrameStats.zig
index cf3b00d3..cabb003b 100644
--- a/src/FrameStats.zig
+++ b/src/FrameStats.zig
@@ -62,6 +62,9 @@ pub const Frame = struct {
rastered: u16 = 0,
/// Bytes a cell shell wrote to its terminal for the frame.
bytes: u32 = 0,
+ /// PDF page rasters that landed in it (rendered on the loop, or taken
+ /// from a lane): the frame a page lands on.
+ landed: u16 = 0,
};
/// Where a frame's work goes, as a game's profiler splits its budget.
@@ -96,6 +99,7 @@ zone_us: [zone_count]u32 = @splat(0),
shaped: u16 = 0,
rastered: u16 = 0,
bytes: u32 = 0,
+landed: u16 = 0,
/// When the timedemo started, monotonic ns (0: none ran), and which.
demo_ns: u64 = 0,
demo_name: []const u8 = "",
@@ -157,8 +161,10 @@ pub fn record(stats: *FrameStats, end_ns: u64, moving: bool, skipped: bool) void
.shaped = stats.shaped,
.rastered = stats.rastered,
.bytes = stats.bytes,
+ .landed = stats.landed,
};
stats.bytes = 0;
+ stats.landed = 0;
stats.input_ns = 0;
stats.zone_us = @splat(0);
stats.shaped = 0;
@@ -270,14 +276,14 @@ 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\tcaret\tlatency_us\tview", .{});
inline for (comptime std.enums.values(Zone)) |which| write.line(fd, &buf, "\t{t}_us", .{which});
- write.line(fd, &buf, "\tshaped\trastered\tbytes\n", .{});
+ write.line(fd, &buf, "\tshaped\trastered\tbytes\tlanded\n", .{});
for (all) |part| for (part) |f| {
write.line(fd, &buf, "{d:.3}\t{d}\t{d}\t{d}\t{d}\t{d}\t{d}\t{d:.4}\t{d:.4}\t{d}\t{d}", .{
@as(f64, @floatFromInt(f.start_ns -| t0)) / std.time.ns_per_ms, f.update_us, f.render_us, f.present_us, f.gap_us,
@intFromBool(f.moving), @intFromBool(f.skipped), f.scroll, f.caret, f.latency_us, f.view,
});
for (f.zones) |us| write.line(fd, &buf, "\t{d}", .{us});
- write.line(fd, &buf, "\t{d}\t{d}\t{d}\n", .{ f.shaped, f.rastered, f.bytes });
+ write.line(fd, &buf, "\t{d}\t{d}\t{d}\t{d}\n", .{ f.shaped, f.rastered, f.bytes, f.landed });
};
}
@@ -320,6 +326,7 @@ pub fn named(name: []const u8) ?[]const Step {
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, "jumps")) return &jumps;
if (std.mem.eql(u8, name, "longlines")) return &longlines;
@@ -518,6 +525,73 @@ pub const pdf_scroll = blk: {
break :blk out;
};
+/// The same, on a manual of 5363 pages (the Intel SDM, combined volumes,
+/// 27 MB: run where `sdm.pdf` is, a copy): its open, a wheel spun both
+/// ways, PageDown held five seconds, a far Look to page 3000 and Back, gg,
+/// a Look at page 4500, then slow notches and a touchpad's drag.
+pub const pdf_sdm = blk: {
+ @setEvalBranchQuota(40_000);
+ var steps: [512]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 = "open" });
+ at.add(&steps, &n, t, .{ .exec = "Look sdm.pdf" });
+ t += 3000;
+ at.add(&steps, &n, t, .{ .phase = "spin" });
+ for (0..6) |_| {
+ at.add(&steps, &n, t, .{ .wheel = 1 });
+ t += 150;
+ }
+ for (0..60) |_| {
+ at.add(&steps, &n, t, .{ .wheel = 1 });
+ t += 8;
+ }
+ t += 600;
+ for (0..30) |_| {
+ at.add(&steps, &n, t, .{ .wheel = -1 });
+ t += 8;
+ }
+ t += 600;
+ at.add(&steps, &n, t, .{ .phase = "held-pagedown" });
+ for (0..150) |_| {
+ at.add(&steps, &n, t, .{ .key = .{ .cp = pardes.Key.page_down } });
+ t += 33;
+ }
+ t += 800;
+ at.add(&steps, &n, t, .{ .phase = "far-jump" });
+ at.add(&steps, &n, t, .{ .exec = "Look sdm.pdf:3000" });
+ t += 1200;
+ at.add(&steps, &n, t, .{ .key = .{ .cp = 'o', .ctrl = true } });
+ t += 1200;
+ at.add(&steps, &n, t, .{ .key = .{ .cp = 'g', .text = "g" } });
+ at.add(&steps, &n, t + 20, .{ .key = .{ .cp = 'g', .text = "g" } });
+ t += 1200;
+ at.add(&steps, &n, t, .{ .phase = "look-deep" });
+ at.add(&steps, &n, t, .{ .exec = "Look sdm.pdf:4500" });
+ t += 1500;
+ at.add(&steps, &n, t, .{ .phase = "slow-notches" });
+ for (0..8) |_| {
+ at.add(&steps, &n, t, .{ .wheel = 1 });
+ t += 300;
+ }
+ at.add(&steps, &n, t, .{ .phase = "slow-touch" });
+ for (0..120) |_| {
+ at.add(&steps, &n, t, .{ .touch = 0.06 });
+ t += 16;
+ }
+ t += 600;
+ 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: {
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index 37e4b216..15e7dac5 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -336,6 +336,8 @@ pub const State = if (enabled) struct {
scroll_to_page_pending: bool = true,
rasters: [raster_max]Raster = undefined,
rasters_len: usize = 0,
+ /// Rasters installed since the last draw (the probe's `landed`).
+ landed: u16 = 0,
spare: [raster_spare][]u8 = @splat(&.{}),
spare_len: usize = 0,
layout_anchor_pending: bool = false,
@@ -1465,6 +1467,7 @@ fn reconcile(
state.next_raster_revision +%= 1;
if (state.next_raster_revision == 0) state.next_raster_revision = 1;
slot.revision = state.next_raster_revision;
+ state.landed +|= 1;
}
state.trimSpares(gpa);
}
@@ -2880,6 +2883,10 @@ pub fn draw(
state.document_scroll_y = shown;
defer state.document_scroll_y = state.drawn_y;
if (pane_id == core.active) core.frames.scroll = @floatCast(shown);
+ defer {
+ core.frames.landed +|= state.landed;
+ state.landed = 0;
+ }
const visible = renderFrame(
state,
core.pdf_gpa,