Skip to documentation
SLOP

tiny.profiling.report.page

Reference tiny.profiling report page

Defined in report.

API (9)

Actions

Public operations.

Values and defaults

Public values and defaults.

No direct callersNo direct callsreportpage
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Called byCallsprivate; no linksrc.profiling.report.pageworkloadFlameLinksreport.sitegeneraterecordsanitizeSegmentreport.pageflameFile
Static calls · unresolved targets: 0 · external targets: 1.
Called byCallstest; no linksrc.profiling.report.pagetest: page run and workload render ta...report.sitegeneratereport.flameloadBlockedreport.flameloadFoldedreport.flamepreviousCpuFoldedreport.flamerenderprivate; no linksrc.profiling.report.pagecallchainQuality+2 morereport.pageflamePage
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallstest; no linksrc.profiling.report.pagetest: page index renders lede trends ...test; no linksrc.profiling.report.pagetest: page renders unsupported outer ...report.sitegenerateprivate; no linksrc.profiling.report.pageindexLedeprivate; no linksrc.profiling.report.pageindexRunsprivate; no linksrc.profiling.report.pageindexTrendsprivate; no linksrc.profiling.report.pageindexVerdictreport.pageindex
Static calls · unresolved targets: 0 · external targets: 2.
Called byCallstest; no linksrc.profiling.report.pagetest: page run and workload render ta...report.sitegenerateprivate; no linksrc.profiling.report.pagememoryMetaprivate; no linksrc.profiling.report.pagememoryScopeSectionprivate; no linksrc.profiling.report.pagememoryWorkloadTablereport.pagememoryPage
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsprivate; no linksrc.profiling.report.pageindexLedetest; no linksrc.profiling.report.pagetest: page index renders lede trends ...test; no linksrc.profiling.report.pagetest: page renders energy and power s...test; no linksrc.profiling.report.pagetest: page renders exact skipped acqu...test; no linksrc.profiling.report.pagetest: page renders unsupported outer ...+2 moreprivate; no linksrc.profiling.report.pagerunAnalysisprivate; no linksrc.profiling.report.pagerunMetaprivate; no linksrc.profiling.report.pagerunWorkloadsreport.pagerun
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallstest; no linksrc.profiling.report.pagetest: page renders failed warmup acqu...test; no linksrc.profiling.report.pagetest: page run and workload render ta...private; no linksrc.profiling.report.pageworkloadAcquisitionMetadatareport.sitegeneratereport.formatkibreport.formatnsreport.formatsecondsprivate; no linksrc.profiling.report.pagemetaItemprivate; no linksrc.profiling.report.pageretainsAllExecutionArtifacts+16 morereport.pageworkload
Static calls · unresolved targets: 0 · external targets: 3.
Called byCallsreport.pageflamePageprivate; no linksrc.profiling.report.pagememoryWorkloadRowprivate; no linksrc.profiling.report.pagerunWorkloadsprivate; no linksrc.profiling.report.pagetrendCardreport.sitegeneraterecordsanitizeSegmentreport.pageworkloadFile
Static calls · unresolved targets: 0 · external targets: 1.

Source: src/profiling/report/page.zig

zig
const std = @import("std");const sys = @import("sys");const zen = @import("zen");const profiling = @import("../root.zig");const analysis = @import("root.zig").analysis;const chart = @import("root.zig").chart;const flame = @import("root.zig").flame;const format = @import("root.zig").format;const model = @import("root.zig").model;const analyze = profiling.analyze;const Allocator = std.mem.Allocator;pub const log_tail_bytes = 8 * 1024;const Html = struct {    allocator: Allocator,    out: std.ArrayList(u8) = .empty,    fn raw(self: *Html, text: []const u8) Allocator.Error!void {        try self.out.appendSlice(self.allocator, text);    }    fn esc(self: *Html, text: []const u8) Allocator.Error!void {        try zen.html.appendEscaped(&self.out, self.allocator, text);    }    fn fmt(self: *Html, comptime f: []const u8, args: anytype) Allocator.Error!void {        const text = try std.fmt.allocPrint(self.allocator, f, args);        defer self.allocator.free(text);        try self.out.appendSlice(self.allocator, text);    }    fn take(self: *Html) Allocator.Error![]u8 {        return try self.out.toOwnedSlice(self.allocator);    }};pub fn index(allocator: Allocator, site: model.Site) ![]u8 {    var html = Html{ .allocator = allocator };    try html.raw("<nav class=\"crumbs\"><a href=\"index.html\">tiny profiling</a></nav>");    try html.raw("<h1>Profiling</h1>");    try indexLede(&html, site);    try indexVerdict(&html, site);    try indexTrends(&html, allocator, site);    try indexRuns(&html, allocator, site);    return try html.take();}fn indexLede(html: *Html, site: model.Site) !void {    const latest = site.latest() orelse {        try html.raw("<p class=\"lede\">No profiling runs found. Run <code>zig build profile-cycle</code> or <code>zig build profile-run</code> first.</p>");        return;    };    try html.fmt("<p class=\"lede\">{d} run(s) · latest <a href=\"runs/", .{site.runs.len});    try html.esc(latest.dir);    try html.raw("/index.html\">");    try html.esc(latest.manifest.run_id);    try html.raw("</a> started ");    try html.esc(try format.timestamp(html.allocator, latest.manifest.started_unix_ns));    try html.raw(" · suite ");    try html.esc(latest.manifest.suite);    try html.fmt(" · {d}/{d} passed</p>", .{ latest.run.passed(), latest.run.ran() });}fn indexVerdict(html: *Html, site: model.Site) !void {    const latest = site.latest() orelse return;    try html.raw("<section><h2>Latest verdict</h2>");    const recorded = latest.recorded orelse {        try html.raw("<p class=\"verdict muted\">The latest run has no recorded analysis. Cycle runs (<code>zig build profile-cycle</code>) record one against the previous cycle.</p></section>");        return;    };    const baseline = recorded.baseline orelse {        try html.raw("<p class=\"verdict muted\">First cycle: baseline recorded, nothing to compare against yet.</p></section>");        return;    };    if (recorded.comparison_support) |support| {        if (!support.supported) {            try html.raw("<p class=\"verdict warn\">Comparison unsupported vs baseline <b>");            try html.esc(baseline.run_id);            try html.raw("</b>: ");            try html.esc(try tokenLabel(html.allocator, support.state));            try html.raw(                ". Runs remain inspectable, but no regression verdict was computed.</p></section>",            );            return;        }    }    if (recorded.order_effects) |effects| {        if (!effects.support.supported) {            try html.raw("<p class=\"verdict warn\">Fixed-vs-random diagnostic unsupported: ");            try html.esc(try tokenLabel(html.allocator, effects.support.state));            try html.raw(".</p>");        } else if (std.mem.eql(u8, effects.status, "order_sensitive_candidate")) {            try html.fmt(                "<p class=\"verdict warn\">{d} order-sensitive workload " ++                    "candidate(s); product regression verdicts remain suppressed.</p>",                .{effects.order_sensitive_workloads},            );        } else {            try html.raw("<p class=\"verdict muted\">Fixed-vs-random diagnostic: ");            try html.esc(try tokenLabel(html.allocator, effects.status));            try html.raw(". This does not establish independence.</p>");        }    }    if (recorded.priority_items.len == 0 and recorded.findings() == 0) {        if (recorded.workload_comparison_skips.len == 0) {            try html.raw("<p class=\"verdict ok\">No regressions above threshold vs baseline <b>");            try html.esc(baseline.run_id);            try html.raw("</b>.</p>");        } else {            try html.fmt("<p class=\"verdict warn\">No supported regressions above threshold; {d} workload comparison(s) skipped vs baseline <b>", .{recorded.workload_comparison_skips.len});            try html.esc(baseline.run_id);            try html.raw("</b>. Details on the <a href=\"runs/");            try html.esc(latest.dir);            try html.raw("/index.html\">run page</a>.</p>");        }    } else {        try html.fmt("<p class=\"verdict warn\">{d} priority item(s), {d} finding(s) vs baseline <b>", .{ recorded.priority_items.len, recorded.findings() });        try html.esc(baseline.run_id);        try html.raw("</b>. Details on the <a href=\"runs/");        try html.esc(latest.dir);        try html.raw("/index.html\">run page</a>.</p>");        try priorityTable(html, recorded.priority_items, 5);    }    try html.raw("</section>");}fn indexTrends(html: *Html, allocator: Allocator, site: model.Site) !void {    if (site.histories.len == 0 or site.runs.len == 0) return;    try html.raw("<section><h2>Trends</h2><p class=\"hint\">");    try html.raw("Mean measured-process wall and peak memory across runs compatible with ");    try html.raw("the latest build and host context, oldest to newest. Incompatible retained ");    try html.raw("runs appear as gaps. ");    try html.raw("Hover points for exact values.</p><div class=\"cards\">");    for (site.histories) |*history| {        try trendCard(html, allocator, site, history);    }    try html.raw("</div></section>");}fn trendCard(html: *Html, allocator: Allocator, site: model.Site, history: *const model.WorkloadHistory) !void {    const latest_dir = latestDirWith(site, history.name) orelse return;    const file = try workloadFile(allocator, history.name);    try html.raw("<div class=\"card\"><h3><a href=\"runs/");    try html.esc(latest_dir);    try html.raw("/workloads/");    try html.esc(file);    try html.raw("\">");    try html.esc(history.name);    try html.raw("</a></h3><p class=\"card-meta\">");    try html.esc(history.package);    if (lastValue(history.wall)) |wall| {        try html.raw(" · mean wall ");        try html.esc(try format.ns(allocator, wall));    }    if (lastDeltaPercent(history.wall)) |delta| {        try html.fmt("<span class=\"{s}\"> ({s})</span>", .{ deltaClass(delta), try format.percent(allocator, delta) });    }    try html.raw("</p>");    try html.raw("<div class=\"trend\"><span class=\"trend-label\">mean wall</span>");    try html.raw(try seriesChart(allocator, site, history.wall, null, null, format.ns, .{ .width = 250, .height = 56 }));    try html.raw("</div>");    if (definedCount(history.rss) > 0) {        try html.raw("<div class=\"trend\"><span class=\"trend-label\">rss</span>");        try html.raw(try seriesChart(allocator, site, history.rss, null, null, format.kib, .{ .width = 250, .height = 40 }));        try html.raw("</div>");    }    try html.raw("</div>");}fn indexRuns(html: *Html, allocator: Allocator, site: model.Site) !void {    if (site.runs.len == 0) return;    try html.raw("<section><h2>Runs</h2><table class=\"data\"><thead><tr>");    try html.raw("<th data-sort>run</th><th data-sort>started</th><th>git</th><th>suite</th><th data-sort>workloads</th><th data-sort>failed</th><th data-sort>wall</th><th data-sort>metrics</th><th data-sort>analysis</th>");    try html.raw("</tr></thead><tbody>");    var display = site.runs.len;    while (display > 0) {        display -= 1;        const entry = &site.runs[display];        try html.raw("<tr><td><a href=\"runs/");        try html.esc(entry.dir);        try html.raw("/index.html\">");        try html.esc(entry.manifest.run_id);        try html.raw("</a></td>");        try html.fmt("<td data-v=\"{d}\">", .{entry.manifest.started_unix_ns});        try html.esc(try format.timestamp(allocator, entry.manifest.started_unix_ns));        try html.raw("</td><td><code>");        try html.esc(format.shortSha(entry.manifest.git_sha));        try html.raw("</code>");        if (entry.manifest.git_dirty orelse false) try html.raw(" <span class=\"badge badge-dirty\">dirty</span>");        try html.raw("</td><td>");        try html.esc(entry.manifest.suite);        try html.fmt("</td><td class=\"num\" data-v=\"{d}\">{d}</td>", .{ entry.run.ran(), entry.run.ran() });        const failed = entry.run.failed();        if (failed == 0) {            try html.fmt("<td class=\"num\" data-v=\"0\">0</td>", .{});        } else {            try html.fmt("<td class=\"num fail\" data-v=\"{d}\">{d}</td>", .{ failed, failed });        }        const wall: f64 = @floatFromInt(entry.manifest.wall_ns orelse 0);        try html.fmt("<td class=\"num\" data-v=\"{d:.0}\">", .{wall});        try html.esc(try format.ns(allocator, wall));        try html.fmt("</td><td class=\"num\" data-v=\"{d}\">{d}</td>", .{ entry.run.metricCount(), entry.run.metricCount() });        if (entry.recorded) |recorded| {            if (recorded.baseline != null) {                try html.fmt("<td data-v=\"{d}\">recorded</td>", .{recorded.priority_items.len});            } else {                try html.raw("<td data-v=\"0\" class=\"muted\">first cycle</td>");            }        } else {            try html.raw("<td data-v=\"-1\" class=\"muted\">none</td>");        }        try html.raw("</tr>");    }    try html.raw("</tbody></table></section>");}pub fn run(allocator: Allocator, entry: *const model.Entry, has_memory: bool) ![]u8 {    var html = Html{ .allocator = allocator };    try html.raw("<nav class=\"crumbs\"><a href=\"../../index.html\">tiny profiling</a> / <span>");    try html.esc(entry.manifest.run_id);    try html.raw("</span></nav><h1>");    try html.esc(entry.manifest.run_id);    try html.raw("</h1>");    try runMeta(&html, allocator, entry);    if (has_memory) {        try html.raw("<p class=\"hint\"><a href=\"memory.html\">Memory accountability</a>: allocation traces reconciled against peak RSS.</p>");    }    try runWorkloads(&html, allocator, entry);    try runAnalysis(&html, allocator, entry);    return try html.take();}pub const memory_file = "memory.html";pub fn memoryPage(allocator: Allocator, entry: *const model.Entry, report: profiling.report.memory.Report) ![]u8 {    var html = Html{ .allocator = allocator };    try html.raw("<nav class=\"crumbs\"><a href=\"../../index.html\">tiny profiling</a> / <a href=\"index.html\">");    try html.esc(entry.manifest.run_id);    try html.raw("</a> / <span>memory</span></nav><h1>");    try html.esc(entry.manifest.run_id);    try html.raw(" memory accountability</h1>");    try html.raw("<p class=\"hint\">Retained bytes from complete allocation traces, " ++        "reconciled against each workload&#39;s peak RSS. Partial traces are shown but " ++        "excluded from coverage. Unclassified is RSS the traces cannot explain: binaries, " ++        "stacks, page-cache, and untraced allocators.</p>");    try memoryMeta(&html, allocator, report.totals);    try memoryWorkloadTable(&html, allocator, report.workloads);    for (report.workloads) |row| try memoryScopeSection(&html, allocator, row);    return try html.take();}fn memoryMeta(    html: *Html,    allocator: Allocator,    totals: profiling.report.memory.Totals,) !void {    try html.raw("<dl class=\"meta\">");    try metaItem(html, "workloads", try std.fmt.allocPrint(allocator, "{d}", .{totals.workloads}));    try metaItem(        html,        "traced",        try std.fmt.allocPrint(allocator, "{d}", .{totals.traced_workloads}),    );    try metaItem(        html,        "complete",        try std.fmt.allocPrint(allocator, "{d}", .{totals.complete_traces}),    );    try metaItem(        html,        "partial",        try std.fmt.allocPrint(allocator, "{d}", .{totals.partial_traces}),    );    try metaItem(html, "rss sum", try format.bytes(allocator, @floatFromInt(totals.rss_bytes_sum)));    try metaItem(        html,        "attributed retained",        try format.bytes(allocator, @floatFromInt(totals.attributed_retained_bytes_sum)),    );    try metaItem(        html,        "unclassified",        try format.bytes(allocator, @floatFromInt(totals.unclassified_bytes_sum)),    );    try html.raw("</dl>");}fn memoryWorkloadTable(    html: *Html,    allocator: Allocator,    workloads: []const profiling.report.memory.Workload,) !void {    try html.raw("<section><h2>Workloads</h2><table class=\"data\"><thead><tr>" ++        "<th data-sort>workload</th><th data-sort>state</th><th data-sort>integrity</th>" ++        "<th data-sort>max rss</th><th data-sort>retained</th>" ++        "<th data-sort>unclassified</th><th data-sort>coverage</th></tr></thead><tbody>");    var max_unclassified: f64 = 1;    for (workloads) |row| {        if (row.accounting.unclassified_bytes) |bytes| max_unclassified = @max(max_unclassified, @as(f64, @floatFromInt(bytes)));    }    for (workloads) |row| try memoryWorkloadRow(html, allocator, row, max_unclassified);    try html.raw("</tbody></table></section>");}fn memoryWorkloadRow(    html: *Html,    allocator: Allocator,    row: profiling.report.memory.Workload,    max_unclassified: f64,) !void {    const file = try workloadFile(allocator, row.name);    try html.raw("<tr><td><a href=\"workloads/");    try html.esc(file);    try html.raw("\">");    try html.esc(row.name);    try html.raw("</a></td><td>");    try html.esc(row.accounting.state);    try html.raw("</td><td>");    if (row.trace) |trace| {        try html.esc(trace.integrity.status);    } else {        try html.raw("<span class=\"muted\">&#8212;</span>");    }    try html.raw("</td>");    try optionalBytesCell(html, allocator, row.accounting.rss_bytes);    try optionalBytesCell(html, allocator, row.accounting.attributed_retained_bytes);    if (row.accounting.unclassified_bytes) |bytes| {        try barCell(            html,            @floatFromInt(bytes),            max_unclassified,            try format.bytes(allocator, @floatFromInt(bytes)),        );    } else {        try html.raw("<td class=\"num muted\" data-v=\"-1\">&#8212;</td>");    }    if (row.accounting.coverage_percent) |coverage| {        try html.fmt(            "<td class=\"num\" data-v=\"{d:.2}\">{d:.1}%</td>",            .{ coverage, coverage },        );    } else {        try html.raw("<td class=\"num muted\" data-v=\"-1\">&#8212;</td>");    }    try html.raw("</tr>");}fn memoryScopeSection(    html: *Html,    allocator: Allocator,    row: profiling.report.memory.Workload,) !void {    const trace = row.trace orelse return;    try html.raw("<section><h3>");    try html.esc(row.name);    try html.raw(" scopes</h3><p class=\"hint\">");    try html.esc(try format.count(allocator, @floatFromInt(trace.summary.events)));    try html.raw(" trace events &#183; ");    try html.esc(try format.count(allocator, @floatFromInt(trace.summary.allocations)));    try html.raw(" allocations &#183; high water ");    try html.esc(try format.bytes(allocator, @floatFromInt(trace.summary.high_water_live_bytes)));    try html.raw(" live &#183; integrity ");    try html.esc(trace.integrity.status);    try html.raw("</p>");    if (trace.integrity.message) |message| {        try html.raw("<p class=\"hint\">Capture caveat: ");        try html.esc(message);        try html.raw(" Action: ");        try html.esc(trace.integrity.action);        try html.raw(".</p>");    }    if (trace.scopes.len == 0) {        try html.raw("<p class=\"muted\">No scopes above the byte floor.</p></section>");        return;    }    try html.raw("<table class=\"data\"><thead><tr><th>scope</th>" ++        "<th data-sort>retained</th><th data-sort>live</th>" ++        "<th data-sort>high water live</th><th data-sort>allocated</th>" ++        "<th data-sort>allocations</th><th data-sort>byte-event area</th>" ++        "<th data-sort>mean lifetime</th>" ++        "</tr></thead><tbody>");    for (trace.scopes) |scope| try memoryScopeRow(html, allocator, scope);    try html.raw("</tbody></table></section>");}fn memoryScopeRow(    html: *Html,    allocator: Allocator,    scope: profiling.report.memory.Scope,) !void {    try html.raw("<tr><td class=\"label\"><code>");    try html.esc(scope.scope);    try html.raw("</code></td>");    try bytesCell(html, allocator, scope.retained_bytes);    try bytesCell(html, allocator, scope.live_bytes);    try bytesCell(html, allocator, scope.high_water_live_bytes);    try bytesCell(html, allocator, scope.allocated_bytes);    try html.fmt(        "<td class=\"num\" data-v=\"{d}\">{d}</td>",        .{ scope.allocations, scope.allocations },    );    try html.fmt(        "<td class=\"num\" data-v=\"{d}\">",        .{scope.lifetime_total_byte_events},    );    try html.esc(try format.count(        allocator,        @floatFromInt(scope.lifetime_total_byte_events),    ));    try html.raw(" byte-events</td>");    try html.fmt(        "<td class=\"num\" data-v=\"{d}\">{d} events</td>",        .{ scope.lifetime_mean_events, scope.lifetime_mean_events },    );    try html.raw("</tr>");}fn bytesCell(html: *Html, allocator: Allocator, bytes: u64) !void {    const value: f64 = @floatFromInt(bytes);    try html.fmt("<td class=\"num\" data-v=\"{d:.0}\">", .{value});    try html.esc(try format.bytes(allocator, value));    try html.raw("</td>");}fn optionalBytesCell(html: *Html, allocator: Allocator, bytes: ?u64) !void {    const actual = bytes orelse {        try html.raw("<td class=\"num muted\" data-v=\"-1\">&#8212;</td>");        return;    };    try bytesCell(html, allocator, actual);}fn runMeta(html: *Html, allocator: Allocator, entry: *const model.Entry) !void {    try html.raw("<dl class=\"meta\">");    try metaItem(html, "started", try format.timestamp(allocator, entry.manifest.started_unix_ns));    if (entry.manifest.wall_ns) |wall| try metaItem(html, "wall", try format.ns(allocator, @floatFromInt(wall)));    try metaItem(html, "suite", entry.manifest.suite);    var git: std.ArrayList(u8) = .empty;    try git.appendSlice(allocator, format.shortSha(entry.manifest.git_sha));    if (entry.manifest.git_branch) |branch| {        try git.appendSlice(allocator, " on ");        try git.appendSlice(allocator, branch);    }    if (entry.manifest.git_dirty orelse false) try git.appendSlice(allocator, " (dirty)");    try metaItem(html, "git", git.items);    if (entry.manifest.zig_version) |version| try metaItem(html, "zig", version);    if (entry.manifest.optimize) |optimize| try metaItem(html, "optimize", optimize);    var host_text: std.ArrayList(u8) = .empty;    if (entry.manifest.host.hostname) |hostname| {        try host_text.appendSlice(allocator, hostname);        try host_text.appendSlice(allocator, ", ");    }    try host_text.appendSlice(allocator, entry.manifest.host.os orelse "unknown");    if (entry.manifest.host.kernel) |kernel| {        try host_text.appendSlice(allocator, " ");        try host_text.appendSlice(allocator, kernel);    }    try host_text.appendSlice(allocator, ", ");    try host_text.appendSlice(allocator, entry.manifest.host.arch orelse "unknown");    try metaItem(html, "host", host_text.items);    var cpu_text: std.ArrayList(u8) = .empty;    try cpu_text.appendSlice(allocator, entry.manifest.host.cpu_model orelse "unknown");    if (entry.manifest.host.cpu_count) |cpus| {        const logical = try std.fmt.allocPrint(allocator, ", {d} logical", .{cpus});        try cpu_text.appendSlice(allocator, logical);    }    try metaItem(html, "cpu", cpu_text.items);    if (entry.manifest.host.cpu_frequency_policy) |policy| {        try metaItem(html, "frequency policy", policy);    }    var placement_text: std.ArrayList(u8) = .empty;    if (entry.manifest.host.process_cpu_affinity) |affinity| {        try placement_text.appendSlice(allocator, "CPUs ");        try placement_text.appendSlice(allocator, affinity);    }    if (entry.manifest.host.process_memory_affinity) |affinity| {        if (placement_text.items.len != 0) try placement_text.appendSlice(allocator, ", ");        try placement_text.appendSlice(allocator, "memory nodes ");        try placement_text.appendSlice(allocator, affinity);    }    if (placement_text.items.len != 0) {        try metaItem(html, "process placement", placement_text.items);    }    const passed_text = try std.fmt.allocPrint(allocator, "{d}/{d}", .{ entry.run.passed(), entry.run.ran() });    try metaItem(html, "passed", passed_text);    try html.raw("</dl>");}fn metaItem(html: *Html, key: []const u8, value: []const u8) !void {    try html.raw("<div><dt>");    try html.esc(key);    try html.raw("</dt><dd>");    try html.esc(value);    try html.raw("</dd></div>");}fn runWorkloads(html: *Html, allocator: Allocator, entry: *const model.Entry) !void {    try html.raw("<section><h2>Workloads</h2>");    if (entry.run.workloads.len == 0) {        try html.raw("<p class=\"muted\">No workload rows recorded.</p></section>");        return;    }    var max_wall: f64 = 1;    var max_rss: f64 = 1;    for (entry.run.workloads) |workload_row| {        max_wall = @max(max_wall, @as(f64, @floatFromInt(workload_row.wall_ns)));        if (workload_row.max_rss_kib) |rss| max_rss = @max(max_rss, @as(f64, @floatFromInt(rss)));    }    try html.raw("<table class=\"data\"><thead><tr><th data-sort>workload</th><th data-sort>package</th><th data-sort>state</th><th data-sort>acquisition</th><th data-sort>mean wall</th><th data-sort>max rss</th><th data-sort>mean cpu</th><th data-sort>warmups</th><th data-sort>executions</th><th data-sort>wall samples</th><th data-sort>timing</th><th data-sort>memory</th><th data-sort>causal</th><th>captures</th></tr></thead><tbody>");    for (entry.run.workloads) |*workload_row| {        const file = try workloadFile(allocator, workload_row.name);        try html.raw("<tr><td><a href=\"workloads/");        try html.esc(file);        try html.raw("\">");        try html.esc(workload_row.name);        try html.raw("</a></td><td>");        try html.esc(workload_row.package);        try html.raw("</td><td>");        try stateBadge(html, workload_row.status, workload_row.exit_code);        const acquisition_sort = switch (workload_row.acquisition) {            .blocked => |blocked| blocked.position,            .random_interleaved => |interleaved| interleaved.positions[0],        };        try html.fmt(            "</td><td data-v=\"{d}\"><code>",            .{acquisition_sort},        );        try html.esc(try acquisitionLabel(allocator, workload_row.acquisition));        try html.raw("</code></td>");        if (workload_row.execution_count == 0) {            try html.raw("<td class=\"num muted\" data-v=\"-1\">—</td>");        } else {            const wall: f64 = @floatFromInt(workload_row.wall_ns);            try barCell(html, wall, max_wall, try format.ns(allocator, wall));        }        if (workload_row.max_rss_kib) |rss| {            const rss_value: f64 = @floatFromInt(rss);            try barCell(html, rss_value, max_rss, try format.kib(allocator, rss_value));        } else {            try html.raw("<td class=\"num muted\" data-v=\"-1\">—</td>");        }        if (workload_row.user_s != null or workload_row.system_s != null) {            const cpu = (workload_row.user_s orelse 0) + (workload_row.system_s orelse 0);            try html.fmt("<td class=\"num\" data-v=\"{d:.3}\">", .{cpu});            try html.esc(try format.seconds(allocator, cpu));        } else {            try html.raw("<td class=\"num muted\" data-v=\"-1\">—");        }        try html.fmt("</td><td class=\"num\" data-v=\"{d}\">{d}</td>", .{ workload_row.warmup_count, workload_row.warmup_count });        try html.fmt("<td class=\"num\" data-v=\"{d}\">{d}</td>", .{ workload_row.execution_count, workload_row.execution_count });        if (workload_row.execution_count == 0) {            try html.raw("<td class=\"num muted\" data-v=\"0\">—</td>");        } else {            const wall_distribution = workloadWallDistribution(workload_row);            try html.fmt(                "<td class=\"num\" data-v=\"{d}\">{d}<br><span class=\"muted\">",                .{ wall_distribution.sample_count, wall_distribution.sample_count },            );            try html.esc(try tokenLabel(allocator, wall_distribution.kind.name()));            try html.raw("</span></td>");        }        try html.fmt("<td class=\"num\" data-v=\"{d}\">{d}</td>", .{ workload_row.metrics.len, workload_row.metrics.len });        try html.fmt("<td class=\"num\" data-v=\"{d}\">{d}</td>", .{ workload_row.memory_metrics.len, workload_row.memory_metrics.len });        try html.fmt("<td class=\"num\" data-v=\"{d}\">{d}</td>", .{ workload_row.causal.len, workload_row.causal.len });        try html.raw("<td>");        if (workload_row.captures.len == 0) {            try html.raw("<span class=\"muted\">—</span>");        } else {            for (workload_row.captures, 0..) |capture, capture_index| {                if (capture_index != 0) try html.raw(", ");                try html.esc(capture.kind);                try html.raw(" (");                try html.esc(capture.state);                try html.raw(")");            }        }        try html.raw("</td></tr>");    }    try html.raw("</tbody></table></section>");}fn runAnalysis(html: *Html, allocator: Allocator, entry: *const model.Entry) !void {    const recorded = entry.recorded orelse return;    try html.raw("<section><h2>Recorded analysis</h2>");    const baseline = recorded.baseline orelse {        try html.raw("<p class=\"verdict muted\">First cycle: this run recorded the baseline, so there is no comparison yet.</p></section>");        return;    };    if (recorded.comparison_support) |support| {        if (!support.supported) {            try html.raw("<p class=\"verdict warn\">Comparison unsupported against baseline <b>");            try html.esc(baseline.run_id);            try html.raw("</b>: ");            try html.esc(try tokenLabel(allocator, support.state));            try html.raw(                ". Evidence remains available for inspection, but regressions and " ++                    "differential views are suppressed.</p></section>",            );            return;        }    }    try html.raw("<p>Compared against baseline <b>");    try html.esc(baseline.run_id);    try html.raw("</b>.</p>");    if (recorded.order_effects) |effects| {        try orderEffectsTable(html, allocator, effects);    }    if (recorded.priority_items.len == 0 and recorded.findings() == 0 and        recorded.energy_shifts.len == 0 and recorded.counter_shifts.len == 0 and        recorded.workload_comparison_skips.len == 0)    {        try html.raw("<p class=\"verdict ok\">No regressions above threshold.</p></section>");        return;    }    if (recorded.priority_items.len != 0) {        try html.raw("<h3>Priority</h3>");        try priorityTable(html, recorded.priority_items, recorded.priority_items.len);    }    if (recorded.priority_components.len != 0) {        try html.raw("<h3>Components</h3><table class=\"data\"><thead><tr><th>component</th><th data-sort>workloads</th><th data-sort>issues</th><th>strongest</th><th data-sort>total score</th><th>reason</th></tr></thead><tbody>");        for (recorded.priority_components) |component| {            try html.raw("<tr><td>");            try html.esc(component.component);            try html.fmt("</td><td class=\"num\">{d}</td><td class=\"num\">{d}</td><td>", .{ component.workloads, component.issues });            try html.esc(component.strongest_label);            try html.fmt("</td><td class=\"num\" data-v=\"{d:.2}\">{d:.2}</td><td>", .{ component.total_score, component.total_score });            try html.esc(component.reason);            try html.raw("</td></tr>");        }        try html.raw("</tbody></table>");    }    if (recorded.workload_comparison_skips.len != 0) {        try html.raw("<h3>Skipped workload comparisons</h3><p class=\"hint\">Outer mean wall and peak RSS were not compared across incompatible measurement or acquisition designs. Structured metrics and profiler evidence keep their own support rules.</p><table class=\"data\"><thead><tr><th>workload</th><th>reason</th><th>baseline acquisition</th><th>candidate acquisition</th><th data-sort>baseline executions</th><th data-sort>candidate executions</th><th data-sort>baseline warmups</th><th data-sort>candidate warmups</th></tr></thead><tbody>");        for (recorded.workload_comparison_skips) |row| {            try html.raw("<tr><td>");            try html.esc(row.workload);            try html.raw("</td><td>");            try html.esc(row.reason);            try html.raw("</td><td><code>");            try html.esc(try acquisitionLabel(allocator, row.baseline_acquisition));            try html.raw("</code></td><td><code>");            try html.esc(try acquisitionLabel(allocator, row.candidate_acquisition));            try html.fmt("</code></td><td class=\"num\" data-v=\"{d}\">{d}</td><td class=\"num\" data-v=\"{d}\">{d}</td><td class=\"num\" data-v=\"{d}\">{d}</td><td class=\"num\" data-v=\"{d}\">{d}</td></tr>", .{                row.baseline_execution_count,                row.baseline_execution_count,                row.candidate_execution_count,                row.candidate_execution_count,                row.baseline_warmup_count,                row.baseline_warmup_count,                row.candidate_warmup_count,                row.candidate_warmup_count,            });        }        try html.raw("</tbody></table>");    }    if (recorded.regressions.len != 0) {        try html.raw("<h3>Mean wall and peak RSS regressions</h3><p class=\"hint\">Wall status uses the independent repetition level. Supported sample regressions have a 95% bootstrap effect interval above threshold; uncertain, summary, and point candidates remain lower-confidence evidence.</p><table class=\"data\"><thead><tr><th>workload</th><th>kind</th><th>status</th><th data-sort>baseline</th><th data-sort>candidate</th><th data-sort>change</th><th>wall samples</th><th>95% wall effect</th></tr></thead><tbody>");        for (recorded.regressions) |row| {            try html.raw("<tr><td>");            try html.esc(row.workload);            try html.raw("</td><td>");            try html.esc(row.kind);            try html.raw("</td><td>");            if (std.mem.indexOf(u8, row.kind, "wall") != null) {                try html.esc(try tokenLabel(allocator, row.wall_status));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.raw("</td><td class=\"num\">");            try html.esc(try format.ns(allocator, row.baseline_wall_ns orelse 0));            try html.raw("</td><td class=\"num\">");            try html.esc(try format.ns(allocator, row.candidate_wall_ns orelse 0));            try html.raw("</td>");            try percentCell(html, allocator, row.wall_percent_change);            try html.raw("<td class=\"num\">");            if (row.baseline_wall_samples != 0 and row.candidate_wall_samples != 0) {                try html.fmt("{d} ", .{row.baseline_wall_samples});                try html.esc(try tokenLabel(allocator, row.baseline_wall_distribution));                try html.fmt("<br>→ {d} ", .{row.candidate_wall_samples});                try html.esc(try tokenLabel(allocator, row.candidate_wall_distribution));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.raw("</td><td class=\"num\">");            if (row.wall_effect_low_percent != null and row.wall_effect_high_percent != null) {                try html.esc(try format.percent(allocator, row.wall_effect_low_percent.?));                try html.raw(" .. ");                try html.esc(try format.percent(allocator, row.wall_effect_high_percent.?));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.raw("</td></tr>");        }        try html.raw("</tbody></table>");    }    if (recorded.metric_regressions.len != 0) {        try html.raw("<h3>Timing metric regressions</h3><table class=\"data\"><thead><tr><th>metric</th><th>status</th><th data-sort>baseline</th><th data-sort>candidate</th><th data-sort>change</th><th>effect</th></tr></thead><tbody>");        for (recorded.metric_regressions) |row| {            try html.raw("<tr><td>");            try html.esc(row.label);            try html.raw("</td><td>");            try html.esc(row.status);            try html.raw("</td><td class=\"num\">");            try html.esc(try format.ns(allocator, row.baseline_ns));            try html.raw("</td><td class=\"num\">");            try html.esc(try format.ns(allocator, row.candidate_ns));            try html.raw("</td>");            try percentCell(html, allocator, row.percent_change);            try html.raw("<td class=\"num\">");            if (row.effect_low_percent != null and row.effect_high_percent != null) {                try html.esc(try format.percent(allocator, row.effect_low_percent.?));                try html.raw(" .. ");                try html.esc(try format.percent(allocator, row.effect_high_percent.?));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.raw("</td></tr>");        }        try html.raw("</tbody></table>");    }    if (recorded.memory_regressions.len != 0) {        try html.raw(            "<h3>Memory regressions</h3><table class=\"data\"><thead><tr>" ++                "<th>metric</th><th>status</th><th data-sort>baseline</th>" ++                "<th data-sort>candidate</th><th data-sort>change</th>" ++                "<th>evidence</th><th>95% effect</th></tr></thead><tbody>",        );        for (recorded.memory_regressions) |row| {            try html.raw("<tr><td>");            try html.esc(row.label);            try html.raw("</td><td>");            try html.esc(try tokenLabel(allocator, row.status));            try html.raw("</td><td class=\"num\">");            try html.esc(try formatMemory(allocator, row.baseline_value, row.unit));            try html.raw("</td><td class=\"num\">");            try html.esc(try formatMemory(allocator, row.candidate_value, row.unit));            try html.raw("</td>");            try percentCell(html, allocator, row.percent_change);            try html.raw("<td><code>");            try html.esc(try tokenLabel(allocator, row.baseline_distribution));            try html.raw(" &#8594; ");            try html.esc(try tokenLabel(allocator, row.candidate_distribution));            try html.fmt(                "</code><br><span class=\"muted\">{d} / {d} samples</span></td>",                .{ row.baseline_samples, row.candidate_samples },            );            try html.raw("<td class=\"num\">");            if (row.effect_low_percent != null and                row.effect_high_percent != null)            {                try html.esc(try format.percent(allocator, row.effect_low_percent.?));                try html.raw(" .. ");                try html.esc(try format.percent(allocator, row.effect_high_percent.?));            } else {                try html.raw("<span class=\"muted\">&#8212;</span>");            }            try html.raw("</td></tr>");        }        try html.raw("</tbody></table>");    }    try energyShiftsTable(html, allocator, recorded.energy_shifts);    if (recorded.counter_shifts.len != 0) {        try html.raw("<h3>Counter shifts</h3><p class=\"hint\">Attribution evidence, never priority input.</p><table class=\"data\"><thead><tr><th>workload</th><th>event</th><th data-sort>baseline</th><th data-sort>candidate</th><th data-sort>change</th><th>status</th></tr></thead><tbody>");        for (recorded.counter_shifts) |row| {            try html.raw("<tr><td>");            try html.esc(row.workload);            try html.raw("</td><td><code>");            try html.esc(row.event);            try html.raw("</code></td><td class=\"num\">");            try html.esc(try format.count(allocator, row.baseline_value));            try html.raw("</td><td class=\"num\">");            try html.esc(try format.count(allocator, row.candidate_value));            try html.raw("</td>");            try percentCell(html, allocator, row.percent_change);            try html.raw("<td>");            try html.esc(row.status);            try html.raw("</td></tr>");        }        try html.raw("</tbody></table>");    }    try html.raw("</section>");}fn energyShiftsTable(    html: *Html,    allocator: Allocator,    rows: []const analysis.EnergyShift,) !void {    if (rows.len == 0) return;    try html.raw(        "<h3>Energy shifts</h3><p class=\"hint\">Repeated system hardware-domain " ++            "evidence, never process attribution or priority input. Caveated rows include " ++            "incomplete or unstable repetition evidence.</p><table class=\"data\"><thead><tr>" ++            "<th>workload</th><th>domain</th><th data-sort>baseline energy</th>" ++            "<th data-sort>candidate energy</th><th data-sort>energy change</th>" ++            "<th data-sort>baseline power</th><th data-sort>candidate power</th>" ++            "<th data-sort>power change</th><th>energy range</th><th>power range</th>" ++            "<th>status</th></tr></thead><tbody>",    );    for (rows) |row| {        try html.raw("<tr><td>");        try html.esc(row.workload);        try html.raw("</td><td><code>");        try html.esc(row.event);        try html.raw("</code></td>");        try energyValueCell(html, row.baseline_joules, "J");        try energyValueCell(html, row.candidate_joules, "J");        try percentCell(html, allocator, row.energy_percent_change);        try optionalEnergyValueCell(html, row.baseline_watts, "W");        try optionalEnergyValueCell(html, row.candidate_watts, "W");        try optionalPercentCell(html, allocator, row.power_percent_change);        try rangePairCell(            html,            allocator,            row.baseline_energy_range_percent,            row.candidate_energy_range_percent,        );        try rangePairCell(            html,            allocator,            row.baseline_power_range_percent,            row.candidate_power_range_percent,        );        try html.raw("<td>");        try html.esc(try tokenLabel(allocator, row.status));        try html.raw("</td></tr>");    }    try html.raw("</tbody></table>");}fn energyValueCell(html: *Html, value: f64, unit: []const u8) !void {    try html.fmt("<td class=\"num\" data-v=\"{d}\">{d:.3} {s}</td>", .{ value, value, unit });}fn optionalEnergyValueCell(html: *Html, value: ?f64, unit: []const u8) !void {    const actual = value orelse {        try html.raw("<td class=\"num muted\">—</td>");        return;    };    try energyValueCell(html, actual, unit);}fn optionalPercentCell(html: *Html, allocator: Allocator, value: ?f64) !void {    const actual = value orelse {        try html.raw("<td class=\"num muted\">—</td>");        return;    };    try percentCell(html, allocator, actual);}fn rangePairCell(    html: *Html,    allocator: Allocator,    baseline: ?f64,    candidate: ?f64,) !void {    try html.raw("<td class=\"num\">");    if (baseline) |value| {        try html.esc(try format.percent(allocator, value));    } else {        try html.raw("<span class=\"muted\">—</span>");    }    try html.raw(" → ");    if (candidate) |value| {        try html.esc(try format.percent(allocator, value));    } else {        try html.raw("<span class=\"muted\">—</span>");    }    try html.raw("</td>");}fn orderEffectsTable(    html: *Html,    allocator: Allocator,    effects: analysis.OrderEffects,) !void {    try html.raw("<h3>Fixed vs random acquisition diagnostic</h3><p>");    try html.esc(effects.fixed_run_id);    try html.raw(" fixed vs ");    try html.esc(effects.random_run_id);    try html.raw(": <b>");    try html.esc(try tokenLabel(allocator, effects.status));    try html.raw("</b>.</p>");    if (!effects.support.supported) {        try html.raw("<p class=\"verdict warn\">Unsupported: ");        try html.esc(try tokenLabel(allocator, effects.support.state));        try html.raw(".</p>");    } else {        try html.raw(            "<table class=\"data\"><thead><tr><th>workload</th>" ++                "<th>classification</th><th>fixed acquisition</th>" ++                "<th>random acquisition</th><th data-sort>fixed mean</th>" ++                "<th data-sort>random mean</th><th data-sort>change</th>" ++                "<th>95% effect</th><th>samples</th></tr></thead><tbody>",        );        for (effects.rows) |row| {            try html.raw("<tr><td>");            try html.esc(row.workload);            try html.raw("</td><td>");            try html.esc(try tokenLabel(allocator, row.classification));            try html.raw("</td><td><code>");            try html.esc(try acquisitionLabel(allocator, row.fixed_acquisition));            try html.raw("</code></td><td><code>");            try html.esc(try acquisitionLabel(allocator, row.random_acquisition));            try html.raw("</code></td><td class=\"num\">");            if (row.fixed_mean_ns) |mean| {                try html.esc(try format.ns(allocator, mean));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.raw("</td><td class=\"num\">");            if (row.random_mean_ns) |mean| {                try html.esc(try format.ns(allocator, mean));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.raw("</td>");            try percentCell(html, allocator, row.mean_percent_change);            try html.raw("<td class=\"num\">");            if (row.effect_low_percent != null and row.effect_high_percent != null) {                try html.esc(try format.percent(allocator, row.effect_low_percent.?));                try html.raw(" .. ");                try html.esc(try format.percent(allocator, row.effect_high_percent.?));            } else {                try html.raw("<span class=\"muted\">—</span>");            }            try html.fmt(                "</td><td class=\"num\">{d} fixed / {d} random</td></tr>",                .{ row.fixed_count, row.random_count },            );        }        try html.raw("</tbody></table>");    }    try html.raw("<p class=\"hint\">Diagnostic limits: ");    for (effects.limits, 0..) |limit, limit_index| {        if (limit_index != 0) try html.raw(" · ");        try html.esc(limit);    }    try html.raw(".</p>");}fn acquisitionLabel(    allocator: Allocator,    acquisition: profiling.order.Context,) ![]const u8 {    std.debug.assert(acquisition.valid());    return switch (acquisition) {        .blocked => |blocked| blocked_label: {            const predecessors = if (blocked.predecessors.len == 0)                "none"            else                try std.mem.join(allocator, ", ", blocked.predecessors);            break :blocked_label try std.fmt.allocPrint(                allocator,                "blocked {d}/{d} after [{s}]",                .{ blocked.position, blocked.workload_count, predecessors },            );        },        .random_interleaved => |interleaved| try std.fmt.allocPrint(            allocator,            "interleaved {d}x/{d}, positions [{s}]",            .{                interleaved.repeat_count,                interleaved.workload_count,                try positionsLabel(allocator, interleaved.positions),            },        ),    };}fn positionsLabel(allocator: Allocator, positions: []const usize) ![]const u8 {    const labels = try allocator.alloc([]const u8, positions.len);    for (positions, 0..) |position, position_index| {        labels[position_index] = try std.fmt.allocPrint(allocator, "{d}", .{position});    }    return try std.mem.join(allocator, ", ", labels);}fn priorityTable(html: *Html, items: []const analysis.PriorityItem, limit: usize) !void {    try html.raw("<table class=\"data\"><thead><tr><th data-sort>rank</th><th data-sort>score</th><th>kind</th><th>workload</th><th>finding</th><th data-sort>change</th><th>evidence</th><th>reason</th></tr></thead><tbody>");    for (items[0..@min(limit, items.len)]) |item| {        try html.fmt("<tr><td class=\"num\">{d}</td><td class=\"num\" data-v=\"{d:.2}\">{d:.2}</td><td>", .{ item.rank, item.score, item.score });        try html.esc(item.kind);        try html.raw("</td><td>");        try html.esc(item.workload);        try html.raw("</td><td>");        try html.esc(item.label);        try html.raw("</td>");        try percentCell(html, html.allocator, item.percent_change);        try html.raw("<td>");        try html.esc(item.evidence);        if (item.confidence.len != 0) {            try html.raw(" / ");            try html.esc(item.confidence);        }        try html.raw("</td><td>");        try html.esc(item.reason);        try html.raw("</td></tr>");    }    try html.raw("</tbody></table>");}pub fn workload(    allocator: Allocator,    site: model.Site,    entry: *const model.Entry,    row: *const analyze.Workload,    flame_sources: flame.Sources,) ![]u8 {    var html = Html{ .allocator = allocator };    try html.raw("<nav class=\"crumbs\"><a href=\"../../../index.html\">tiny profiling</a> / <a href=\"../index.html\">");    try html.esc(entry.manifest.run_id);    try html.raw("</a> / <span>");    try html.esc(row.name);    try html.raw("</span></nav><h1>");    try html.esc(row.name);    try html.raw(" ");    try stateBadge(&html, row.status, row.exit_code);    try html.raw("</h1>");    try html.raw("<dl class=\"meta\">");    try metaItem(&html, "package", row.package);    try metaItem(&html, "step", row.step);    try workloadAcquisitionMetadata(&html, allocator, row.acquisition);    try metaItem(        &html,        "mean wall",        if (row.execution_count == 0)            "not measured"        else            try format.ns(allocator, @floatFromInt(row.wall_ns)),    );    try metaItem(&html, "measurement executions", try std.fmt.allocPrint(allocator, "{d}", .{row.execution_count}));    if (row.execution_count != 0) try workloadWallMetadata(&html, allocator, row);    try workloadWarmupMetadata(&html, allocator, row);    if (row.execution_count > 1) {        try metaItem(&html, "acquisition wall", try format.ns(allocator, @floatFromInt(row.total_wall_ns)));        try metaItem(            &html,            "workload outputs",            if (retainsAllExecutionArtifacts(row))                "all measured executions"            else                "profiler capture contract",        );    }    try workloadStructuredAnalysisMetadata(&html, row);    if (row.max_rss_kib) |rss| try metaItem(&html, "max rss", try format.kib(allocator, @floatFromInt(rss)));    if (row.user_s) |user| try metaItem(&html, "mean user cpu", try format.seconds(allocator, user));    if (row.system_s) |system| try metaItem(&html, "mean system cpu", try format.seconds(allocator, system));    try workloadResourceMetadata(&html, allocator, row);    if (row.capture_perturbation) |measurement| {        try metaItem(&html, "capture-control state", try tokenLabel(allocator, @tagName(measurement.state)));        try metaItem(&html, "capture-control pairs", try std.fmt.allocPrint(allocator, "{d}", .{measurement.pairs.len}));    }    try html.raw("</dl>");    try workloadCapturePerturbation(&html, allocator, row);    try workloadBenchmarkReduction(&html, allocator, row);    try workloadTiming(&html, allocator, site, row);    try workloadMemory(&html, allocator, site, row);    try workloadCausal(&html, allocator, row);    try workloadFlameLinks(&html, allocator, row, flame_sources);    try workloadCaptures(&html, row);    try workloadExecutionArtifacts(&html, allocator, row);    try workloadLogs(&html, allocator, row);    return try html.take();}fn retainsAllExecutionArtifacts(row: *const analyze.Workload) bool {    if (row.executions.len == 0) return false;    for (row.executions) |execution| {        if (execution.artifacts == null) return false;    }    return true;}fn workloadStructuredAnalysisMetadata(    html: *Html,    row: *const analyze.Workload,) !void {    switch (row.benchmark_process_reduction) {        .complete => |complete| try metaItem(            html,            "benchmark process reduction",            try std.fmt.allocPrint(                html.allocator,                "{d} process medians · deterministic 95% bootstrap",                .{complete.sources.len},            ),        ),        .not_applicable => |value| {            if (row.executions.len < 2) return;            try metaItem(                html,                "benchmark process reduction",                try tokenLabel(html.allocator, @tagName(value.reason)),            );        },    }}fn workloadBenchmarkReduction(    html: *Html,    allocator: Allocator,    row: *const analyze.Workload,) !void {    const complete = switch (row.benchmark_process_reduction) {        .not_applicable => return,        .complete => |value| value,    };    try html.raw("<section id=\"benchmark-process-reduction\">");    try html.raw("<h2>Benchmark process reduction</h2>");    try html.raw(        "<p class=\"hint\">Each value is one verified lib/bench process median " ++            "in measured acquisition order. The center is their median; " ++            "uncertainty is a deterministic 95% percentile-bootstrap interval.</p>",    );    try html.raw("<table class=\"data\"><thead><tr>");    try html.raw("<th>benchmark</th><th>process medians (ns)</th>");    try html.raw("<th data-sort>median</th><th>95% interval</th>");    try html.raw("<th>allocation maxima</th></tr></thead><tbody>");    for (complete.benchmarks) |benchmark_value| {        try benchmarkReductionRow(html, allocator, benchmark_value);    }    try html.raw("</tbody></table>");    try benchmarkReductionSources(html, complete.sources);    try html.raw("</section>");}fn benchmarkReductionRow(    html: *Html,    allocator: Allocator,    benchmark_value: profiling.reduction.Benchmark,) !void {    try html.raw("<tr><td class=\"label\"><code>");    try html.esc(benchmark_value.suite);    try html.raw(" / ");    try html.esc(benchmark_value.id);    try html.raw("</code></td><td><code>");    for (benchmark_value.sample_ns, 0..) |sample, sample_index| {        if (sample_index != 0) try html.raw(" → ");        try html.fmt("{d}", .{sample});    }    try html.raw("</code></td><td class=\"num\" data-v=\"");    try html.fmt("{d}\">", .{benchmark_value.statistics.median_ns});    try html.esc(try format.ns(        allocator,        @floatFromInt(benchmark_value.statistics.median_ns),    ));    try html.raw("</td><td>");    try html.esc(try format.ns(        allocator,        benchmark_value.statistics.median_interval.low_ns,    ));    try html.raw(" – ");    try html.esc(try format.ns(        allocator,        benchmark_value.statistics.median_interval.high_ns,    ));    try html.raw("</td><td>");    try benchmarkAllocationMaxima(html, benchmark_value.allocation_maxima);    try html.raw("</td></tr>");}fn benchmarkAllocationMaxima(    html: *Html,    maxima: profiling.reduction.AllocationMaxima,) !void {    if (maxima.alloc_count == null) {        try html.raw("not tracked");        return;    }    try html.fmt(        "{d} alloc / {d} free · {d} B",        .{ maxima.alloc_count.?, maxima.free_count.?, maxima.alloc_bytes.? },    );    try html.raw("<br><span class=\"muted\">");    try html.fmt(        "{d} alloc / {d} free · {d} B per eval",        .{            maxima.alloc_count_per_eval.?,            maxima.free_count_per_eval.?,            maxima.alloc_bytes_per_eval.?,        },    );    try html.raw("</span>");}fn benchmarkReductionSources(    html: *Html,    sources: []const profiling.reduction.Source,) !void {    try html.fmt(        "<details><summary>Digest-bound source receipts ({d})</summary>",        .{sources.len},    );    try html.raw("<table class=\"data\"><thead><tr>");    try html.raw("<th data-sort>execution</th><th data-sort>acquisition</th>");    try html.raw("<th>bench JSONL</th><th>structured wrapper</th>");    try html.raw("</tr></thead><tbody>");    for (sources) |source| try benchmarkReductionSourceRow(html, source);    try html.raw("</tbody></table></details>");}fn benchmarkReductionSourceRow(    html: *Html,    source: profiling.reduction.Source,) !void {    const bench_digest = source.bench_jsonl.identity.hex();    const structured_digest = source.structured.identity.hex();    try html.fmt("<tr><td class=\"num\">{d}</td><td class=\"num\">", .{        source.execution_index,    });    if (source.acquisition_position) |position| {        try html.fmt("{d}", .{position});    } else {        try html.raw("fixed");    }    try html.raw("</td><td><code>");    try html.esc(source.bench_jsonl.path);    try html.raw("</code><br><span class=\"muted\"><code>");    try html.esc(bench_digest[0..12]);    try html.fmt("…</code> · {d} B</span></td><td><code>", .{        source.bench_jsonl.identity.bytes,    });    try html.esc(source.structured.path);    try html.raw("</code><br><span class=\"muted\"><code>");    try html.esc(structured_digest[0..12]);    try html.fmt("…</code> · {d} B</span></td></tr>", .{        source.structured.identity.bytes,    });}fn workloadAcquisitionMetadata(    html: *Html,    allocator: Allocator,    acquisition: profiling.order.Context,) !void {    std.debug.assert(acquisition.valid());    try metaItem(html, "measurement order", acquisition.method().name());    switch (acquisition) {        .blocked => |blocked| {            try metaItem(                html,                "acquisition position",                try std.fmt.allocPrint(                    allocator,                    "{d} of {d}",                    .{ blocked.position, blocked.workload_count },                ),            );            try metaItem(                html,                "preceded by",                if (blocked.predecessors.len == 0)                    "none"                else                    try std.mem.join(allocator, " → ", blocked.predecessors),            );        },        .random_interleaved => |interleaved| {            try metaItem(                html,                "schedule algorithm",                profiling.order.schedule_algorithm,            );            try metaItem(                html,                "interleave seed",                try std.fmt.allocPrint(allocator, "{d}", .{interleaved.seed}),            );            try metaItem(                html,                "acquisition design",                try std.fmt.allocPrint(                    allocator,                    "{d} workload(s) × {d} repetitions",                    .{ interleaved.workload_count, interleaved.repeat_count },                ),            );            try metaItem(                html,                "selected cohort",                try std.mem.join(allocator, " → ", interleaved.selected_workloads),            );            try metaItem(                html,                "planned positions",                try positionsLabel(allocator, interleaved.positions),            );            try metaItem(html, "setup order", profiling.order.setup_order);            try metaItem(                html,                "warmup placement",                profiling.order.warmup_placement,            );            try metaItem(html, "failure policy", profiling.order.failure_policy);        },    }}fn workloadCapturePerturbation(    html: *Html,    allocator: Allocator,    row: *const analyze.Workload,) !void {    const measurement = row.capture_perturbation orelse return;    const summary = row.capture_perturbation_summary orelse return;    try html.raw("<section><h2>Capture perturbation</h2><p class=\"hint\">Matched control and capture executions reuse one setup and the same built binary. A seeded balanced order limits drift; the paired interval estimates active-capture wall-time perturbation and is not product-regression priority evidence.</p>");    try html.raw("<dl class=\"meta\">");    try metaItem(html, "effect state", try tokenLabel(allocator, summary.state));    try metaItem(html, "pair order", "seeded balanced within pair");    if (measurement.configuration.host_kind) |kind| {        try metaItem(html, "active host capture", try tokenLabel(allocator, kind));    }    if (measurement.configuration.tracy) {        try metaItem(html, "active Tracy capture", "enabled");    }    if (measurement.configuration.allocations) {        try metaItem(html, "active allocation trace", "enabled");    }    try metaItem(html, "capture artifacts", "last capture execution");    try metaItem(html, "control outputs", "last control execution");    if (summary.control_mean_ns) |value| {        try metaItem(html, "control mean", try format.ns(allocator, value));    }    if (summary.capture_mean_ns) |value| {        try metaItem(html, "capture mean", try format.ns(allocator, value));    }    if (summary.mean_delta_ns) |value| {        try metaItem(html, "mean delta", try signedNs(allocator, value));    }    if (summary.mean_percent_change) |value| {        try metaItem(html, "mean change", try signedPercent(allocator, value));    }    if (summary.effect_low_percent != null and summary.effect_high_percent != null) {        try metaItem(            html,            "95% paired effect",            try std.fmt.allocPrint(                allocator,                "{s} .. {s}",                .{                    try signedPercent(allocator, summary.effect_low_percent.?),                    try signedPercent(allocator, summary.effect_high_percent.?),                },            ),        );    }    try html.raw("</dl><table class=\"data\"><thead><tr><th data-sort>pair</th><th>order</th><th data-sort>control wall</th><th data-sort>capture wall</th><th data-sort>change</th><th>status</th></tr></thead><tbody>");    for (measurement.pairs) |pair| {        try html.fmt("<tr><td class=\"num\" data-v=\"{d}\">{d}</td><td>", .{ pair.index, pair.index });        try html.esc(try tokenLabel(allocator, @tagName(pair.order)));        try html.raw("</td>");        try executionWallCell(html, allocator, pair.control);        try executionWallCell(html, allocator, pair.capture);        try html.raw("<td class=\"num\">");        if (pairPercentChange(pair)) |value| {            try html.esc(try signedPercent(allocator, value));        } else {            try html.raw("<span class=\"muted\">—</span>");        }        try html.raw("</td><td>");        try html.esc(pairState(pair));        try html.raw("</td></tr>");    }    try html.raw("</tbody></table></section>");}fn signedNs(allocator: Allocator, value: f64) ![]const u8 {    return try std.fmt.allocPrint(        allocator,        "{s}{s}",        .{ if (value >= 0) "+" else "", try format.ns(allocator, value) },    );}fn signedPercent(allocator: Allocator, value: f64) ![]const u8 {    return try std.fmt.allocPrint(        allocator,        "{s}{d:.2}%",        .{ if (value >= 0) "+" else "", value },    );}fn executionWallCell(    html: *Html,    allocator: Allocator,    result: ?profiling.execute.Result,) !void {    const actual = result orelse {        try html.raw("<td class=\"num muted\">—</td>");        return;    };    try html.fmt("<td class=\"num\" data-v=\"{d}\">", .{actual.wall_ns});    try html.esc(try format.ns(allocator, @floatFromInt(actual.wall_ns)));    try html.raw("</td>");}fn pairPercentChange(pair: profiling.perturbation.Pair) ?f64 {    const control = pair.control orelse return null;    const captured = pair.capture orelse return null;    if (control.wall_ns == 0) return null;    return ((@as(f64, @floatFromInt(captured.wall_ns)) /        @as(f64, @floatFromInt(control.wall_ns))) - 1.0) * 100.0;}fn pairState(pair: profiling.perturbation.Pair) []const u8 {    const control = pair.control orelse return "not run";    if (control.exit_code != 0) return "control failed";    const captured = pair.capture orelse return "not run";    if (captured.exit_code != 0) return "capture failed";    return "complete";}fn workloadWallMetadata(    html: *Html,    allocator: Allocator,    row: *const analyze.Workload,) !void {    const wall_distribution = workloadWallDistribution(row);    try metaItem(        html,        "wall sample shape",        try tokenLabel(allocator, wall_distribution.kind.name()),    );    try metaItem(        html,        "wall samples",        try std.fmt.allocPrint(            allocator,            "{d}",            .{wall_distribution.sample_count},        ),    );    if (wall_distribution.median_ns) |value| {        try metaItem(html, "wall median", try format.ns(allocator, value));    }    if (wall_distribution.p95_ns) |value| {        try metaItem(html, "wall p95", try format.ns(allocator, value));    }    if (wall_distribution.p99_ns) |value| {        try metaItem(html, "wall p99", try format.ns(allocator, value));    }    if (wall_distribution.stddev_ns) |value| {        try metaItem(            html,            "wall standard deviation",            try format.ns(allocator, value),        );    }    if (wall_distribution.coefficient_of_variation_percent) |value| {        try metaItem(            html,            "wall coefficient of variation",            try std.fmt.allocPrint(allocator, "{d:.2}%", .{value}),        );    }    if (wall_distribution.min_ns != null and wall_distribution.max_ns != null) {        try metaItem(            html,            "wall range",            try std.fmt.allocPrint(                allocator,                "{s} .. {s}",                .{                    try format.ns(allocator, wall_distribution.min_ns.?),                    try format.ns(allocator, wall_distribution.max_ns.?),                },            ),        );    }}fn workloadWarmupMetadata(    html: *Html,    allocator: Allocator,    row: *const analyze.Workload,) !void {    if (row.warmup_count == 0) return;    try metaItem(html, "unmeasured warmups", try std.fmt.allocPrint(allocator, "{d}", .{row.warmup_count}));    try metaItem(html, "warmup wall total", try format.ns(allocator, @floatFromInt(row.warmup_total_wall_ns)));    try metaItem(html, "warmup outputs", "last warmup execution");    const distribution = row.warmup_distribution orelse return;    if (distribution.median_ns) |value| {        try metaItem(html, "warmup wall median", try format.ns(allocator, value));    }    if (distribution.min_ns != null and distribution.max_ns != null) {        try metaItem(            html,            "warmup wall range",            try std.fmt.allocPrint(                allocator,                "{s} .. {s}",                .{                    try format.ns(allocator, distribution.min_ns.?),                    try format.ns(allocator, distribution.max_ns.?),                },            ),        );    }}fn workloadResourceMetadata(    html: *Html,    allocator: Allocator,    row: *const analyze.Workload,) !void {    if (row.resource_usage_source) |source| {        try metaItem(html, "resource usage source", try tokenLabel(allocator, @tagName(source)));    }    if (row.voluntary_context_switches != null and row.involuntary_context_switches != null) {        const switches = row.voluntary_context_switches.? + row.involuntary_context_switches.?;        try metaItem(            html,            "mean context switches",            try std.fmt.allocPrint(                allocator,                "{d:.2} voluntary + {d:.2} involuntary",                .{ row.voluntary_context_switches.?, row.involuntary_context_switches.? },            ),        );        try resourceRateMetadata(html, allocator, "context switches / s", switches, row.wall_ns);    }    if (row.minor_page_faults != null and row.major_page_faults != null) {        const faults = row.minor_page_faults.? + row.major_page_faults.?;        try metaItem(            html,            "mean page faults",            try std.fmt.allocPrint(                allocator,                "{d:.2} minor + {d:.2} major",                .{ row.minor_page_faults.?, row.major_page_faults.? },            ),        );        try resourceRateMetadata(html, allocator, "page faults / s", faults, row.wall_ns);    }}fn resourceRateMetadata(    html: *Html,    allocator: Allocator,    label: []const u8,    value: f64,    wall_ns: u64,) !void {    if (wall_ns == 0) return;    const rate = value * @as(f64, std.time.ns_per_s) /        @as(f64, @floatFromInt(wall_ns));    try metaItem(        html,        label,        try std.fmt.allocPrint(allocator, "{d:.2} process rate", .{rate}),    );}fn workloadWallDistribution(    row: *const analyze.Workload,) profiling.measurement.WallDistribution {    return row.wall_distribution orelse        profiling.measurement.pointWallDistribution(row.wall_ns);}fn tokenLabel(allocator: Allocator, token: []const u8) ![]const u8 {    const label = try allocator.dupe(u8, token);    for (label) |*byte| {        if (byte.* == '_') byte.* = ' ';    }    return label;}fn workloadFlameLinks(html: *Html, allocator: Allocator, row: *const analyze.Workload, flame_sources: flame.Sources) !void {    if (!flame_sources.any()) return;    const file = try flameFile(allocator, row.name);    try html.raw("<section><h2>Flame graphs</h2><p class=\"hint\">");    if (flame_sources.cpu_folded != null) {        try html.raw("<a href=\"");        try html.esc(file);        try html.raw("#cpu\">On-CPU samples</a>");    }    if (flame_sources.offcpu_summary != null) {        if (flame_sources.cpu_folded != null) try html.raw(" · ");        try html.raw("<a href=\"");        try html.esc(file);        try html.raw("#offcpu\">Off-CPU time</a>");    }    try html.raw("</p></section>");}fn workloadTiming(    html: *Html,    allocator: Allocator,    site: model.Site,    row: *const analyze.Workload,) !void {    if (row.metrics.len == 0) return;    const order = try sortedMetricIndices(allocator, row.metrics);    try html.raw(        "<section><h2>Timing metrics</h2><p class=\"hint\">History runs oldest to " ++            "newest. Within-run lines connect explicitly ordered acquisition indices, not " ++            "elapsed time; unordered rows use a distribution strip. Shading is the median " ++            "confidence interval.</p>",    );    try html.raw(        "<table class=\"data\"><thead><tr><th data-sort>metric</th><th>history</th>" ++            "<th>within run</th><th data-sort>median</th><th>95% CI</th>" ++            "<th data-sort>samples</th><th data-sort>min</th><th data-sort>p95</th>" ++            "<th data-sort>max</th></tr></thead><tbody>",    );    const history = site.findHistory(row.name);    for (order) |metric_index| {        const metric = row.metrics[metric_index];        const primary = metric.primaryNs() orelse continue;        try html.raw("<tr><td class=\"label\">");        try html.esc(metric.label);        try html.raw("</td><td>");        try metricHistoryChart(html, allocator, site, history, metric.key);        try html.raw("</td><td>");        try metricWithinRunChart(html, allocator, metric, primary);        try html.fmt("</td><td class=\"num\" data-v=\"{d:.0}\">", .{primary});        try html.esc(try format.ns(allocator, primary));        try html.raw("</td><td class=\"num\">");        if (metric.primaryInterval()) |interval| {            try html.esc(try format.ns(allocator, interval.low_ns));            try html.raw(" .. ");            try html.esc(try format.ns(allocator, interval.high_ns));        } else {            try html.raw("<span class=\"muted\">—</span>");        }        try html.raw("</td>");        if (metric.sample_count) |samples| {            try html.fmt("<td class=\"num\" data-v=\"{d}\">{d}</td>", .{ samples, samples });        } else {            try html.raw("<td class=\"num muted\" data-v=\"0\">—</td>");        }        try optionalNsCell(html, allocator, metric.min_ns);        try optionalNsCell(html, allocator, metric.p95_ns);        try optionalNsCell(html, allocator, metric.max_ns);        try html.raw("</tr>");    }    try html.raw("</tbody></table></section>");}fn metricWithinRunChart(    html: *Html,    allocator: Allocator,    metric: profiling.metric.Metric,    primary: f64,) !void {    const interval = metric.primaryInterval();    const low = if (interval) |actual| actual.low_ns else null;    const high = if (interval) |actual| actual.high_ns else null;    if (metric.samples_ns.len != 0) {        if (metric.sample_sequence) |sample_sequence| {            switch (sample_sequence.order) {                .measured_acquisition_order => {                    try html.raw(try chart.sequence(                        allocator,                        metric.samples_ns,                        primary,                        low,                        high,                        .{                            .format = format.ns,                            .width = 200,                            .height = 34,                            .index_origin = sample_sequence.index_origin,                        },                    ));                    return;                },            }        }    }    if (metric.samples_ns.len != 0 or interval != null) {        try html.raw(try chart.strip(            allocator,            metric.samples_ns,            primary,            low,            high,            .{ .format = format.ns, .width = 200, .height = 34 },        ));        return;    }    try html.raw("<span class=\"muted\">");    try distributionName(html, metric.distribution);    try html.raw("</span>");}fn workloadMemory(    html: *Html,    allocator: Allocator,    site: model.Site,    row: *const analyze.Workload,) !void {    if (row.memory_metrics.len == 0) return;    try html.raw("<section><h2>Memory metrics</h2><table class=\"data\"><thead><tr><th data-sort>metric</th><th>history</th><th data-sort>value</th></tr></thead><tbody>");    const history = site.findHistory(row.name);    for (row.memory_metrics) |metric| {        try html.raw("<tr><td class=\"label\">");        try html.esc(metric.label);        try html.raw("</td><td>");        try memoryHistoryChart(html, allocator, site, history, metric.key, metric.unit.name());        try html.fmt("</td><td class=\"num\" data-v=\"{d:.0}\">", .{metric.value});        try html.esc(try formatMemory(allocator, metric.value, metric.unit.name()));        try html.raw("</td></tr>");    }    try html.raw("</tbody></table></section>");}fn workloadCausal(html: *Html, allocator: Allocator, row: *const analyze.Workload) !void {    if (row.causal.len == 0) return;    try html.raw("<section><h2>Causal (Coz)</h2>");    try causalIntegrityNotice(html, row.captures);    try html.raw(        "<p class=\"hint\">Max program speedup predicted by virtually speeding this line up. " ++            "Larger is a better optimization target. The curve plots program speedup against " ++            "virtual speedup; a rising curve means the line is on the critical path. Experiment " ++            "support counts randomized performance experiments; samples count selected profiler " ++            "samples. Point-only and unreplicated curves are exploratory and do not affect " ++            "regression priority. Repeated curves are directional and require validation with " ++            "independent runs.</p>",    );    try html.raw("<table class=\"data\"><thead><tr><th>location</th>" ++        "<th>progress point</th><th>kind</th><th data-sort>support</th><th>curve</th>" ++        "<th data-sort>max speedup</th><th data-sort>slope</th>" ++        "<th data-sort>experiments</th><th data-sort>samples</th>" ++        "</tr></thead><tbody>");    for (row.causal) |result| {        try html.raw("<tr><td><code>");        try html.esc(result.file);        try html.fmt(":{d}</code></td><td>", .{result.line});        try html.esc(result.progress_point);        try html.raw("</td><td>");        try html.esc(result.kind);        try html.raw("</td>");        try causalSupportCell(html, result.support);        try html.raw("<td>");        try causalCurve(html, allocator, result.measurements);        try html.raw("</td>");        const speedup = result.max_program_speedup * 100;        try html.fmt("<td class=\"num\" data-v=\"{d:.2}\">", .{speedup});        try html.esc(try format.percent(allocator, speedup));        try html.raw("</td><td class=\"num\">");        if (result.slope) |slope| {            try html.fmt("{d:.2}", .{slope});        } else {            try html.raw("<span class=\"muted\">—</span>");        }        try html.fmt("</td><td class=\"num\" data-v=\"{d}\">{d}</td>", .{            result.support.experiment_count,            result.support.experiment_count,        });        try html.fmt("<td class=\"num\" data-v=\"{d}\">{d}</td></tr>", .{            result.total_selected_samples,            result.total_selected_samples,        });    }    try html.raw("</tbody></table></section>");}fn causalSupportCell(html: *Html, support: profiling.capture.coz.Support) !void {    if (support.status == .within_run_repeated_curve) {        try html.raw("<td>");    } else {        try html.raw("<td class=\"warn\">");    }    try html.esc(supportLabel(support.status));    try html.fmt(        "<br><span class=\"muted\">{d} {s}; {d} baseline; " ++            "{d} min/point</span></td>",        .{            support.speedup_point_count,            if (support.speedup_point_count == 1) "point" else "points",            support.baseline_experiment_count,            support.minimum_experiments_per_point,        },    );}fn supportLabel(status: profiling.capture.coz.SupportStatus) []const u8 {    return switch (status) {        .point_only => "point only",        .unreplicated_curve => "unreplicated curve",        .within_run_repeated_curve => "within-run repeated curve",    };}fn causalIntegrityNotice(html: *Html, captures: []const profiling.host.Capture) !void {    for (captures) |capture| {        if (!std.mem.eql(u8, capture.kind, profiling.capture.coz.capture_kind)) continue;        const message = capture.caveat_message orelse {            try html.raw("<p class=\"hint\">Sampling integrity: complete.</p>");            return;        };        try html.raw("<p class=\"verdict warn\">Sampling integrity caveat: ");        try html.esc(message);        try html.raw("</p>");        return;    }}fn causalCurve(html: *Html, allocator: Allocator, measurements: []const profiling.capture.coz.Measurement) !void {    if (measurements.len == 0) {        try html.raw("<span class=\"muted\">—</span>");        return;    }    const points = try allocator.alloc(chart.XyPoint, measurements.len);    for (points, measurements) |*point, measurement| {        const virtual = measurement.virtual_speedup * 100;        const program = measurement.program_speedup * 100;        point.* = .{            .x = virtual,            .y = program,            .label = try std.fmt.allocPrint(allocator, "virtual {s}: program {s}", .{                try format.percent(allocator, virtual),                try format.percent(allocator, program),            }),        };    }    try html.raw(try chart.xy(allocator, points, .{}));}fn workloadCaptures(html: *Html, row: *const analyze.Workload) !void {    if (row.captures.len == 0) return;    try html.raw("<section><h2>Host captures</h2><table class=\"data\"><thead><tr><th>kind</th><th>tool</th><th>scope</th><th>state</th><th>caveat</th></tr></thead><tbody>");    for (row.captures) |capture| {        try html.raw("<tr><td>");        try html.esc(capture.kind);        try html.raw("</td><td>");        try html.esc(capture.tool);        try html.raw("</td><td>");        try html.esc(capture.scope);        try html.raw("</td><td>");        try html.esc(capture.state);        try html.raw("</td><td>");        if (capture.caveat_message) |message| {            try html.esc(message);        } else {            try html.raw("<span class=\"muted\">—</span>");        }        try html.raw("</td></tr>");    }    try html.raw("</tbody></table></section>");}fn workloadLogs(html: *Html, allocator: Allocator, row: *const analyze.Workload) !void {    try logDetails(        html,        allocator,        "warmup stdout (last warmup execution)",        row.warmup_stdout_path,    );    try logDetails(        html,        allocator,        "warmup stderr (last warmup execution)",        row.warmup_stderr_path,    );    if (row.executions.len == 1) {        const execution = row.executions[0];        if (execution.artifacts) |artifacts| {            const prefix = try std.fmt.allocPrint(                allocator,                "measured execution {d}",                .{execution.index},            );            try logDetails(                html,                allocator,                try std.fmt.allocPrint(allocator, "{s} stdout", .{prefix}),                artifacts.stdout,            );            try logDetails(                html,                allocator,                try std.fmt.allocPrint(allocator, "{s} stderr", .{prefix}),                artifacts.stderr,            );        }    }    if (row.profiler_artifacts) |artifacts| {        try logDetails(html, allocator, "profiler stdout (last execution)", artifacts.stdout);        try logDetails(html, allocator, "profiler stderr (last execution)", artifacts.stderr);    }    if (row.capture_perturbation) |measurement| {        try logDetails(            html,            allocator,            "control stdout (last control execution)",            measurement.control_artifacts.stdout,        );        try logDetails(            html,            allocator,            "control stderr (last control execution)",            measurement.control_artifacts.stderr,        );    }}fn workloadExecutionArtifacts(    html: *Html,    allocator: Allocator,    row: *const analyze.Workload,) !void {    var retained: usize = 0;    for (row.executions) |execution| {        if (execution.artifacts != null) retained += 1;    }    if (retained == 0) return;    try html.raw("<details><summary>Measured execution artifacts (");    try html.esc(try std.fmt.allocPrint(allocator, "{d}", .{retained}));    try html.raw(")</summary><table class=\"data\"><thead><tr>");    try html.raw("<th>sample</th><th>PID</th><th>position</th>");    try html.raw("<th>exit</th><th>wall</th><th>stdout</th><th>stderr</th>");    try html.raw("<th>benchmark JSONL</th><th>structured receipt</th>");    try html.raw("<th>rows/errors</th></tr></thead><tbody>");    for (row.executions) |execution| {        const artifacts = execution.artifacts orelse continue;        try html.raw("<tr><td>");        try html.esc(try std.fmt.allocPrint(allocator, "{d}", .{execution.index}));        try html.raw("</td><td>");        try optionalInteger(html, allocator, execution.pid);        try html.raw("</td><td>");        try optionalInteger(html, allocator, execution.acquisition_position);        try html.raw("</td><td>");        try html.esc(try std.fmt.allocPrint(allocator, "{d}", .{execution.exit_code}));        try html.raw("</td><td>");        try html.esc(try format.ns(allocator, @floatFromInt(execution.wall_ns)));        inline for (.{            artifacts.stdout,            artifacts.stderr,            artifacts.bench_jsonl,            artifacts.structured,        }) |path| {            try html.raw("</td><td><code>");            try html.esc(path);            try html.raw("</code>");        }        try html.raw("</td><td>");        try html.esc(try std.fmt.allocPrint(            allocator,            "{d}/{d}",            .{ artifacts.structured_rows, artifacts.structured_parse_errors },        ));        try html.raw("</td></tr>");    }    try html.raw("</tbody></table></details>");}fn optionalInteger(html: *Html, allocator: Allocator, value: anytype) !void {    if (value) |actual| {        try html.esc(try std.fmt.allocPrint(allocator, "{d}", .{actual}));    } else {        try html.raw("<span class=\"muted\">—</span>");    }}fn logDetails(html: *Html, allocator: Allocator, name: []const u8, path: ?[]const u8) !void {    const actual_path = path orelse return;    const text = sys.fs.readFileAlloc(allocator, actual_path, 256 * 1024 * 1024) catch return;    if (std.mem.trim(u8, text, " \t\r\n").len == 0) return;    const tail = text[text.len - @min(text.len, log_tail_bytes) ..];    try html.raw("<details class=\"log\"><summary>");    try html.esc(name);    if (tail.len < text.len) {        try html.fmt(" (last {d} of {d} bytes)", .{ tail.len, text.len });    } else {        try html.fmt(" ({d} bytes)", .{text.len});    }    try html.raw("</summary><pre>");    try html.esc(tail);    try html.raw("</pre></details>");}fn metricHistoryChart(    html: *Html,    allocator: Allocator,    site: model.Site,    history: ?*const model.WorkloadHistory,    key: []const u8,) !void {    const actual = history orelse {        try html.raw("<span class=\"muted\">—</span>");        return;    };    for (actual.metrics) |metric_history| {        if (!std.mem.eql(u8, metric_history.key, key)) continue;        try html.raw(try seriesChart(allocator, site, metric_history.primary, metric_history.low, metric_history.high, format.ns, .{ .width = 170, .height = 34 }));        return;    }    try html.raw("<span class=\"muted\">—</span>");}fn memoryHistoryChart(    html: *Html,    allocator: Allocator,    site: model.Site,    history: ?*const model.WorkloadHistory,    key: []const u8,    unit: []const u8,) !void {    const actual = history orelse {        try html.raw("<span class=\"muted\">—</span>");        return;    };    for (actual.memory) |memory_history| {        if (!std.mem.eql(u8, memory_history.key, key)) continue;        const formatter: chart.Format = if (std.mem.eql(u8, unit, "bytes")) format.bytes else format.count;        try html.raw(try seriesChart(allocator, site, memory_history.values, null, null, formatter, .{ .width = 170, .height = 34 }));        return;    }    try html.raw("<span class=\"muted\">—</span>");}const SeriesOptions = struct {    width: f64,    height: f64,};fn seriesChart(    allocator: Allocator,    site: model.Site,    values: []?f64,    low: ?[]?f64,    high: ?[]?f64,    formatter: chart.Format,    options: SeriesOptions,) ![]u8 {    const points = try allocator.alloc(chart.Point, values.len);    for (points, 0..) |*point, run_index| {        const entry = &site.runs[run_index];        const label = try std.fmt.allocPrint(allocator, "{s} ({s})", .{            entry.manifest.run_id,            try format.timestamp(allocator, entry.manifest.started_unix_ns),        });        point.* = .{            .label = label,            .value = values[run_index],            .low = if (low) |actual| actual[run_index] else null,            .high = if (high) |actual| actual[run_index] else null,        };    }    return try chart.line(allocator, points, .{        .width = options.width,        .height = options.height,        .format = formatter,    });}fn sortedMetricIndices(allocator: Allocator, metrics: []const profiling.metric.Metric) ![]usize {    const order = try allocator.alloc(usize, metrics.len);    for (order, 0..) |*slot, metric_index| slot.* = metric_index;    std.mem.sort(usize, order, metrics, metricGreater);    return order;}fn metricGreater(metrics: []const profiling.metric.Metric, left: usize, right: usize) bool {    const left_value = metrics[left].primaryNs() orelse -1;    const right_value = metrics[right].primaryNs() orelse -1;    return left_value > right_value;}fn stateBadge(html: *Html, status: []const u8, exit_code: i64) !void {    if (exit_code == 0) {        try html.raw("<span class=\"badge badge-passed\">");        try html.esc(status);        try html.raw("</span>");    } else {        try html.fmt("<span class=\"badge badge-failed\">", .{});        try html.esc(status);        try html.fmt(" (exit {d})</span>", .{exit_code});    }}fn barCell(html: *Html, value: f64, max: f64, text: []const u8) !void {    const fraction = if (max > 0) @min(value / max, 1.0) else 0;    try html.fmt("<td class=\"num bar-cell\" data-v=\"{d:.0}\"><span class=\"cellbar\" style=\"width:{d:.1}%\"></span><span class=\"cellval\">", .{ value, fraction * 100 });    try html.esc(text);    try html.raw("</span></td>");}fn distributionName(html: *Html, distribution: profiling.metric.Distribution) !void {    for (distribution.name()) |byte| {        try html.esc(if (byte == '_') " " else &[_]u8{byte});    }}fn optionalNsCell(html: *Html, allocator: Allocator, value: ?f64) !void {    const actual = value orelse {        try html.raw("<td class=\"num muted\" data-v=\"-1\">—</td>");        return;    };    try html.fmt("<td class=\"num\" data-v=\"{d:.0}\">", .{actual});    try html.esc(try format.ns(allocator, actual));    try html.raw("</td>");}fn percentCell(html: *Html, allocator: Allocator, value: ?f64) !void {    const actual = value orelse {        try html.raw("<td class=\"num muted\" data-v=\"0\">—</td>");        return;    };    try html.fmt("<td class=\"num {s}\" data-v=\"{d:.2}\">", .{ deltaClass(actual), actual });    try html.esc(try format.percent(allocator, actual));    try html.raw("</td>");}fn deltaClass(percent: f64) []const u8 {    if (percent >= 2) return "delta-up";    if (percent <= -2) return "delta-down";    return "delta-flat";}fn formatMemory(allocator: Allocator, value: f64, unit: []const u8) ![]u8 {    if (std.mem.eql(u8, unit, "bytes")) return try format.bytes(allocator, value);    return try format.count(allocator, value);}pub fn flamePage(    allocator: Allocator,    site: model.Site,    entry: *const model.Entry,    row: *const analyze.Workload,    flame_sources: flame.Sources,) ![]u8 {    var html = Html{ .allocator = allocator };    const file = try workloadFile(allocator, row.name);    try html.raw("<nav class=\"crumbs\"><a href=\"../../../index.html\">tiny profiling</a> / <a href=\"../index.html\">");    try html.esc(entry.manifest.run_id);    try html.raw("</a> / <a href=\"");    try html.esc(file);    try html.raw("\">");    try html.esc(row.name);    try html.raw("</a> / <span>flame graphs</span></nav><h1>");    try html.esc(row.name);    try html.raw(" flame graphs</h1><p class=\"hint\">Frame width is inclusive weight, merged left-heavy. Click a frame to zoom into its subtree; click the root frame to reset. Hover for exact weights.</p>");    if (flame_sources.cpu_folded) |path| {        const stacks = try flame.loadFolded(allocator, path);        try html.raw("<section id=\"cpu\"><h2>On-CPU samples</h2><p class=\"hint\">Where CPU time went while the workload was running, from perf call-graph samples. Reported depth excludes the command root. An unresolved leaf limits direct attribution; unresolved anywhere means some calling context is missing.</p>");        try callchainQuality(&html, allocator, flame_sources);        try html.raw(try flame.render(allocator, stacks, .{            .class = "flame-cpu",            .palette = .warm,            .format = format.count,            .unit = "samples",        }));        try html.raw("</section>");        if (try flame.previousCpuFolded(allocator, site, entry, row.name)) |previous| {            const baseline_stacks = try flame.loadFolded(allocator, previous.path);            try html.raw("<section id=\"cpu-diff\"><h2>On-CPU change vs ");            try html.esc(previous.run_id);            try html.raw("</h2><p class=\"hint\">Layout is this run; color is the shift in sample share against the earlier run: red grew, blue shrank, near-white unchanged. Frames that vanished entirely tint their ancestors blue.</p>");            try html.raw(try flame.render(allocator, stacks, .{                .class = "flame-diff",                .palette = .warm,                .format = format.count,                .unit = "samples",                .baseline = baseline_stacks,            }));            try html.raw("</section>");        }    }    if (flame_sources.offcpu_summary) |path| {        if (try flame.loadBlocked(allocator, path)) |blocked| {            const nanoseconds = std.mem.eql(u8, blocked.weight_unit, "nanoseconds");            try html.raw("<section id=\"offcpu\"><h2>Off-CPU time</h2><p class=\"hint\">Where the workload was blocked instead of running: synchronization, blocking I/O, and scheduling.</p>");            try html.raw(try flame.render(allocator, blocked.stacks, .{                .class = "flame-offcpu",                .palette = .cool,                .format = if (nanoseconds) format.ns else format.count,                .unit = if (nanoseconds) "blocked" else "events",            }));            try html.raw("</section>");        }    }    try flameSummaries(&html, allocator, flame_sources);    try html.raw("<script>");    try html.raw(flame.script);    try html.raw("</script>");    return try html.take();}fn callchainQuality(    html: *Html,    allocator: Allocator,    flame_sources: flame.Sources,) !void {    const path = flame_sources.symbols_summary orelse {        try html.raw("<p class=\"hint\">Callchain quality was not recorded for this capture.</p>");        return;    };    const summary = (try flame.loadSymbols(allocator, path)) orelse {        try html.raw("<p class=\"hint\">Callchain quality was not recorded for this capture.</p>");        return;    };    const quality = summary.callchain_quality orelse {        try html.raw("<p class=\"hint\">Callchain quality was not recorded for this capture.</p>");        return;    };    try html.raw("<dl class=\"meta callchain-quality\">");    const samples = if (summary.sample_count_text) |reported|        try std.fmt.allocPrint(            allocator,            "{d} extracted · {s} reported",            .{ quality.sample_count, reported },        )    else        try std.fmt.allocPrint(allocator, "{d} extracted", .{quality.sample_count});    try metaItem(html, "callchain samples", samples);    try metaItem(        html,        "unique callchains",        try std.fmt.allocPrint(allocator, "{d}", .{quality.unique_callchain_count}),    );    if (quality.meanDepthFrames()) |mean_depth| try metaItem(        html,        "depth",        try std.fmt.allocPrint(            allocator,            "{d:.1} mean · {d} max",            .{ mean_depth, quality.maximum_depth_frames },        ),    );    if (quality.resolvedFramePercent()) |resolved_percent| try metaItem(        html,        "resolved frames",        try std.fmt.allocPrint(            allocator,            "{d:.2}% · {d} / {d}",            .{                resolved_percent,                quality.resolved_frame_count,                quality.weighted_frame_count,            },        ),    );    if (quality.unresolvedLeafPercent()) |unresolved_leaf_percent| try metaItem(        html,        "unresolved leaves",        try std.fmt.allocPrint(            allocator,            "{d} · {d:.2}%",            .{ quality.unresolved_leaf_samples, unresolved_leaf_percent },        ),    );    if (quality.unresolvedContextPercent()) |unresolved_context_percent| try metaItem(        html,        "unresolved anywhere",        try std.fmt.allocPrint(            allocator,            "{d} · {d:.2}%",            .{                quality.samples_with_unresolved_frames,                unresolved_context_percent,            },        ),    );    try html.raw("</dl>");}fn flameSummaries(html: *Html, allocator: Allocator, flame_sources: flame.Sources) !void {    if (flame_sources.children_summary) |path| {        if (try flame.loadChildren(allocator, path)) |summary| {            if (summary.rows.len != 0) {                try html.raw("<section id=\"symbols\"><h2>Hot symbols</h2><p class=\"hint\">Recorded perf report rows above the lane's percent floor. Children counts a symbol and everything it calls; self counts the symbol alone.</p>");                try html.raw("<table class=\"data\"><thead><tr><th data-sort>children</th><th data-sort>self</th><th>symbol</th><th data-sort>object</th></tr></thead><tbody>");                for (summary.rows) |row| {                    try html.fmt("<tr><td class=\"num\" data-v=\"{d:.2}\">{d:.2}%</td><td class=\"num\" data-v=\"{d:.2}\">{d:.2}%</td><td class=\"label\"><code>", .{ row.children_overhead_percent, row.children_overhead_percent, row.self_overhead_percent, row.self_overhead_percent });                    try html.esc(row.symbol);                    try html.raw("</code></td><td>");                    try html.esc(row.shared_object);                    try html.raw("</td></tr>");                }                try html.raw("</tbody></table></section>");            }        }    } else if (flame_sources.symbols_summary) |path| {        if (try flame.loadSymbols(allocator, path)) |summary| {            if (summary.rows.len != 0) {                try html.raw("<section id=\"symbols\"><h2>Hot symbols</h2><p class=\"hint\">Recorded perf report rows above the lane's percent floor, self overhead only.</p>");                try html.raw("<table class=\"data\"><thead><tr><th data-sort>self</th><th>symbol</th><th data-sort>object</th></tr></thead><tbody>");                for (summary.rows) |row| {                    try html.fmt("<tr><td class=\"num\" data-v=\"{d:.2}\">{d:.2}%</td><td class=\"label\"><code>", .{ row.overhead_percent, row.overhead_percent });                    try html.esc(row.symbol);                    try html.raw("</code></td><td>");                    try html.esc(row.shared_object);                    try html.raw("</td></tr>");                }                try html.raw("</tbody></table></section>");            }        }    }    if (flame_sources.srcline_summary) |path| {        if (try flame.loadSrcline(allocator, path)) |summary| {            if (summary.rows.len != 0) {                try html.raw("<section id=\"srclines\"><h2>Hot source lines</h2>");                try html.raw("<table class=\"data\"><thead><tr><th data-sort>self</th><th>source line</th><th>symbol</th></tr></thead><tbody>");                for (summary.rows) |row| {                    try html.fmt("<tr><td class=\"num\" data-v=\"{d:.2}\">{d:.2}%</td><td class=\"label\"><code>", .{ row.overhead_percent, row.overhead_percent });                    try html.esc(row.source_line);                    try html.raw("</code></td><td class=\"label\"><code>");                    try html.esc(row.symbol);                    try html.raw("</code></td></tr>");                }                try html.raw("</tbody></table></section>");            }        }    }}pub fn workloadFile(allocator: Allocator, name: []const u8) ![]u8 {    const segment = try profiling.record.sanitizeSegment(allocator, name);    defer allocator.free(segment);    return try std.fmt.allocPrint(allocator, "{s}.html", .{segment});}pub fn flameFile(allocator: Allocator, name: []const u8) ![]u8 {    const segment = try profiling.record.sanitizeSegment(allocator, name);    defer allocator.free(segment);    return try std.fmt.allocPrint(allocator, "{s}.flame.html", .{segment});}fn latestDirWith(site: model.Site, workload_name: []const u8) ?[]const u8 {    var run_index = site.runs.len;    while (run_index > 0) {        run_index -= 1;        const entry = &site.runs[run_index];        if (entry.findWorkload(workload_name) != null) return entry.dir;    }    return null;}fn lastValue(values: []?f64) ?f64 {    var value_index = values.len;    while (value_index > 0) {        value_index -= 1;        if (values[value_index]) |value| return value;    }    return null;}fn lastDeltaPercent(values: []?f64) ?f64 {    var defined: [2]f64 = undefined;    var seen: usize = 0;    var value_index = values.len;    while (value_index > 0 and seen < 2) {        value_index -= 1;        if (values[value_index]) |value| {            defined[seen] = value;            seen += 1;        }    }    if (seen < 2) return null;    if (defined[1] == 0) return null;    return (defined[0] - defined[1]) / defined[1] * 100;}fn definedCount(values: []?f64) usize {    var total: usize = 0;    for (values) |value| {        if (value != null) total += 1;    }    return total;}test "page causal curve plots measurements and dashes empty results" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    var with_points = Html{ .allocator = allocator };    const measurements = [_]profiling.capture.coz.Measurement{        .{ .virtual_speedup = 0.0, .program_speedup = 0.0, .experiment_count = 2 },        .{ .virtual_speedup = 0.2, .program_speedup = 0.14, .experiment_count = 2 },        .{ .virtual_speedup = 0.5, .program_speedup = 0.31, .experiment_count = 2 },    };    try causalCurve(&with_points, allocator, &measurements);    const curve = try with_points.take();    try std.testing.expect(std.mem.indexOf(u8, curve, "chart-xy-figure") != null);    try std.testing.expect(std.mem.indexOf(u8, curve, "virtual +50.0%: program +31.0%") != null);    var without_points = Html{ .allocator = allocator };    try causalCurve(&without_points, allocator, &.{});    try std.testing.expect(std.mem.indexOf(u8, try without_points.take(), "muted") != null);}test "page distinguishes exploratory and repeated causal support" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    var exploratory = Html{ .allocator = allocator };    try causalSupportCell(&exploratory, .{        .status = .unreplicated_curve,        .speedup_point_count = 2,        .experiment_count = 2,        .baseline_experiment_count = 1,        .minimum_experiments_per_point = 1,    });    const exploratory_content = try exploratory.take();    try std.testing.expect(std.mem.indexOf(u8, exploratory_content, "class=\"warn\"") != null);    try std.testing.expect(std.mem.indexOf(u8, exploratory_content, "unreplicated curve") != null);    try std.testing.expect(std.mem.indexOf(        u8,        exploratory_content,        "2 points; 1 baseline",    ) != null);    var repeated = Html{ .allocator = allocator };    try causalSupportCell(&repeated, .{        .status = .within_run_repeated_curve,        .speedup_point_count = 3,        .experiment_count = 9,        .baseline_experiment_count = 3,        .minimum_experiments_per_point = 3,    });    const repeated_content = try repeated.take();    try std.testing.expect(std.mem.indexOf(u8, repeated_content, "class=\"warn\"") == null);    try std.testing.expect(std.mem.indexOf(        u8,        repeated_content,        "within-run repeated curve",    ) != null);}test "page renders causal sampling integrity beside results" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    var html = Html{ .allocator = allocator };    const captures = [_]profiling.host.Capture{.{        .kind = profiling.capture.coz.capture_kind,        .tool = profiling.capture.coz.capture_tool,        .capture_path = "bench.coz.jsonl",        .summary_path = "bench.coz.analysis.json",        .state = "summary_written",        .caveat_kind = "sample_loss",        .caveat_message = "perf reported lost sampling events",    }};    try causalIntegrityNotice(&html, &captures);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "Sampling integrity caveat") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "lost sampling events") != null);    var complete_html = Html{ .allocator = allocator };    var complete_capture = captures[0];    complete_capture.caveat_kind = null;    complete_capture.caveat_message = null;    try causalIntegrityNotice(&complete_html, &.{complete_capture});    try std.testing.expect(std.mem.indexOf(        u8,        try complete_html.take(),        "Sampling integrity: complete",    ) != null);}test "page index renders lede trends and runs" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const profiling_dir = ".zig-cache/profile-web-page-index-test";    defer sys.fs.deleteTree(profiling_dir) catch {};    try model.writeTestFixture(allocator, profiling_dir);    const site = try model.load(allocator, profiling_dir);    const content = try index(allocator, site);    try std.testing.expect(std.mem.indexOf(u8, content, "2 run(s)") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "runs/run-200-bbb/index.html") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "gpalloc.allocator") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "chart-line-figure") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "no recorded analysis") != null);}test "page renders unsupported outer comparisons without a regression verdict" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const profiling_dir = ".zig-cache/profile-web-page-context-test";    defer sys.fs.deleteTree(profiling_dir) catch {};    try model.writeTestFixture(allocator, profiling_dir);    const analysis_path = try std.fs.path.join(        allocator,        &.{ profiling_dir, "run-200-bbb", "analysis.json" },    );    try sys.fs.writeFile(analysis_path,        \\{"schema":"tiny.profiling.analysis/v1",        \\ "candidate":{"run_id":"run-200-bbb","ran":1,"passed":1,"failed":0,        \\   "structured_metrics":1,"memory_metrics":1},        \\ "baseline":{"run_id":"run-100-aaa","ran":1,"passed":1,"failed":0,        \\   "structured_metrics":1,"memory_metrics":1},        \\ "comparison_support":{"state":"hostname_mismatch","supported":false},        \\ "regressions":[],"metric_regressions":[],"memory_regressions":[],        \\ "counter_shifts":[],"workload_comparison_skips":[],        \\ "priority":{"items":[],"components":[]}}    );    const site = try model.load(allocator, profiling_dir);    const index_content = try index(allocator, site);    try std.testing.expect(std.mem.indexOf(u8, index_content, "Comparison unsupported") != null);    try std.testing.expect(std.mem.indexOf(u8, index_content, "hostname mismatch") != null);    try std.testing.expect(        std.mem.indexOf(u8, index_content, "No regressions above threshold vs baseline") == null,    );    const run_content = try run(allocator, site.latest().?, true);    try std.testing.expect(std.mem.indexOf(u8, run_content, "Comparison unsupported") != null);    try std.testing.expect(        std.mem.indexOf(u8, run_content, "differential views are suppressed") != null,    );}test "page renders exact skipped acquisition contexts" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const profiling_dir = ".zig-cache/profile-web-page-acquisition-test";    defer sys.fs.deleteTree(profiling_dir) catch {};    try model.writeTestFixture(allocator, profiling_dir);    const analysis_path = try std.fs.path.join(        allocator,        &.{ profiling_dir, "run-200-bbb", "analysis.json" },    );    try sys.fs.writeFile(analysis_path,        \\{"schema":"tiny.profiling.analysis/v1",        \\ "candidate":{"run_id":"run-200-bbb","ran":1,"passed":1,"failed":0,        \\   "structured_metrics":1,"memory_metrics":1},        \\ "baseline":{"run_id":"run-100-aaa","ran":1,"passed":1,"failed":0,        \\   "structured_metrics":1,"memory_metrics":1},        \\ "comparison_support":{"state":"supported","supported":true},        \\ "regressions":[],"metric_regressions":[],"memory_regressions":[],        \\ "counter_shifts":[],"workload_comparison_skips":[{        \\   "workload":"gpalloc.allocator","state":"measurement_order_mismatch",        \\   "reason":"measurement acquisition designs differ",        \\   "baseline_acquisition":{"position":2,"workload_count":2,"predecessors":["choir.compiler"]},        \\   "candidate_acquisition":{"position":2,"workload_count":2,"predecessors":["choir.wasm-emitter"]},        \\   "baseline_execution_count":1,"candidate_execution_count":1,        \\   "baseline_warmup_count":0,"candidate_warmup_count":0}],        \\ "priority":{"items":[],"components":[]}}    );    const site = try model.load(allocator, profiling_dir);    const content = try run(allocator, site.latest().?, true);    try std.testing.expect(std.mem.indexOf(u8, content, "baseline acquisition") != null);    try std.testing.expect(        std.mem.indexOf(u8, content, "2/2 after [choir.compiler]") != null,    );    try std.testing.expect(        std.mem.indexOf(u8, content, "2/2 after [choir.wasm-emitter]") != null,    );}test "page renders energy and power shifts with repetition ranges" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const profiling_dir = ".zig-cache/profile-web-page-energy-test";    defer sys.fs.deleteTree(profiling_dir) catch {};    try model.writeTestFixture(allocator, profiling_dir);    const analysis_path = try std.fs.path.join(        allocator,        &.{ profiling_dir, "run-200-bbb", "analysis.json" },    );    try sys.fs.writeFile(analysis_path,        \\{"schema":"tiny.profiling.analysis/v1",        \\ "candidate":{"run_id":"run-200-bbb","ran":1,"passed":1,"failed":0,        \\   "structured_metrics":1,"memory_metrics":1},        \\ "baseline":{"run_id":"run-100-aaa","ran":1,"passed":1,"failed":0,        \\   "structured_metrics":1,"memory_metrics":1},        \\ "comparison_support":{"state":"supported","supported":true},        \\ "regressions":[],"metric_regressions":[],"memory_regressions":[],        \\ "energy_shifts":[{"workload":"smg.graph","event":"power/energy-pkg/u",        \\   "baseline_joules":10,"candidate_joules":10.5,"energy_percent_change":5,        \\   "baseline_watts":5,"candidate_watts":7,"power_percent_change":40,        \\   "baseline_energy_range_percent":2,"candidate_energy_range_percent":3,        \\   "baseline_power_range_percent":4,"candidate_power_range_percent":5,        \\   "status":"energy_shift_caveated"}],        \\ "counter_shifts":[],"workload_comparison_skips":[],        \\ "priority":{"items":[],"components":[]}}    );    const site = try model.load(allocator, profiling_dir);    const content = try run(allocator, site.latest().?, true);    try std.testing.expect(std.mem.indexOf(u8, content, "Energy shifts") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "power/energy-pkg/u") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "10.000 J") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "7.000 W") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "+2.0% → +3.0%") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "energy shift caveated") != null);}test "page renders measured execution artifacts" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const artifacts = profiling.measurement.ExecutionArtifacts{        .root = "workloads/w/executions/001",        .stdout = "workloads/w/executions/001/stdout.txt",        .stderr = "workloads/w/executions/001/stderr.txt",        .bench_jsonl = "workloads/w/executions/001/bench.jsonl",        .coz_jsonl = "workloads/w/executions/001/bench.coz.jsonl",        .coz_analysis = "workloads/w/executions/001/bench.coz.analysis.json",        .tracy_jsonl = "workloads/w/executions/001/bench.tracy.jsonl",        .tracy_summary = "workloads/w/executions/001/bench.tracy.summary.jsonl",        .allocations = "workloads/w/executions/001/allocations.jsonl",        .structured = "workloads/w/executions/001/structured.jsonl",        .structured_rows = 7,        .structured_parse_errors = 1,    };    const executions = [_]profiling.measurement.Execution{.{        .index = 1,        .acquisition_position = 4,        .pid = 101,        .exit_code = 0,        .wall_ns = 10,        .artifacts = artifacts,    }};    const row = analyze.Workload{        .name = "w",        .package = "p",        .step = "bench",        .status = "passed",        .exit_code = 0,        .wall_ns = 10,        .executions = &executions,        .result_path = null,    };    var html = Html{ .allocator = allocator };    try workloadExecutionArtifacts(&html, allocator, &row);    const content = try html.take();    try std.testing.expect(        std.mem.indexOf(u8, content, "Measured execution artifacts (1)") != null,    );    try std.testing.expect(std.mem.indexOf(u8, content, "structured.jsonl") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "7/1") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "last execution") == null);    const repeated = [_]profiling.measurement.Execution{        executions[0],        executions[0],    };    var repeated_row = row;    repeated_row.executions = &repeated;    repeated_row.benchmark_process_reduction = .{ .not_applicable = .{        .reason = .outside_direct_benchmark_domain,        .process_count = repeated.len,    } };    var metadata = Html{ .allocator = allocator };    try workloadStructuredAnalysisMetadata(&metadata, &repeated_row);    const metadata_content = try metadata.take();    try std.testing.expect(        std.mem.indexOf(u8, metadata_content, "outside direct benchmark domain") != null,    );}fn expectBenchmarkReductionContent(content: []const u8) !void {    try std.testing.expect(std.mem.indexOf(        u8,        content,        "Benchmark process reduction",    ) != null);    try std.testing.expect(std.mem.indexOf(u8, content, "10 → 20") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "128 B") != null);    try std.testing.expect(        std.mem.indexOf(u8, content, "Digest-bound source") != null,    );    try std.testing.expect(std.mem.indexOf(u8, content, "abababababab") != null);}test "page renders benchmark process reduction evidence" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const identity = profiling.fingerprint.File{        .bytes = 42,        .sha256 = @splat(0xab),    };    const sources = [_]profiling.reduction.Source{        .{            .execution_index = 1,            .acquisition_position = 2,            .structured_bench_path = "one/bench.jsonl",            .bench_jsonl = .{ .path = "one/bench.jsonl", .identity = identity },            .structured = .{ .path = "one/structured.jsonl", .identity = identity },        },        .{            .execution_index = 2,            .acquisition_position = 5,            .structured_bench_path = "two/bench.jsonl",            .bench_jsonl = .{ .path = "two/bench.jsonl", .identity = identity },            .structured = .{ .path = "two/structured.jsonl", .identity = identity },        },    };    const samples = [_]u64{ 10, 20 };    const counts = [_]u32{ 4, 4 };    const benchmarks = [_]profiling.reduction.Benchmark{.{        .key = "5:suite4:parse",        .suite = "suite",        .id = "parse",        .allocation_attribution = .sample_call,        .sample_ns = &samples,        .inner_sample_count = &counts,        .statistics = .{            .min_ns = 10,            .max_ns = 20,            .mean_ns = 15,            .median_ns = 20,            .p75_ns = 20,            .p95_ns = 20,            .p99_ns = 20,            .total_ns = 30,            .median_interval = .{ .low_ns = 10, .high_ns = 20 },        },        .allocation_maxima = .{            .alloc_count = 4,            .free_count = 4,            .alloc_bytes = 128,            .alloc_count_per_eval = 1,            .free_count_per_eval = 1,            .alloc_bytes_per_eval = 32,        },    }};    const row = analyze.Workload{        .name = "w",        .package = "p",        .step = "bench",        .status = "passed",        .exit_code = 0,        .wall_ns = 10,        .benchmark_process_reduction = .{ .complete = .{            .sources = &sources,            .benchmarks = &benchmarks,        } },        .result_path = null,    };    var html = Html{ .allocator = allocator };    try workloadBenchmarkReduction(&html, allocator, &row);    try expectBenchmarkReductionContent(try html.take());}test "page renders unmeasured warmup metadata" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const row = analyze.Workload{        .name = "w",        .package = "p",        .step = "bench",        .status = "passed",        .exit_code = 0,        .wall_ns = 10,        .warmup_count = 2,        .warmup_total_wall_ns = 12,        .warmup_distribution = .{            .kind = .raw_executions,            .sample_count = 2,            .mean_ns = 6,            .min_ns = 5,            .median_ns = 6,            .max_ns = 7,        },        .max_rss_kib = null,        .user_s = null,        .system_s = null,        .result_path = null,    };    var html = Html{ .allocator = allocator };    try workloadWarmupMetadata(&html, allocator, &row);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "unmeasured warmups") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "last warmup execution") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "warmup wall median") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "warmup wall range") != null);}test "page renders waited-command scheduler and fault resources" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const row = analyze.Workload{        .name = "w",        .package = "p",        .step = "bench",        .status = "passed",        .exit_code = 0,        .wall_ns = std.time.ns_per_s,        .resource_usage_source = .wait4_rusage,        .minor_page_faults = 96,        .major_page_faults = 1,        .voluntary_context_switches = 2,        .involuntary_context_switches = 1,        .result_path = null,    };    var html = Html{ .allocator = allocator };    try workloadResourceMetadata(&html, allocator, &row);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "wait4 rusage") != null);    try std.testing.expect(        std.mem.indexOf(u8, content, "2.00 voluntary + 1.00 involuntary") != null,    );    try std.testing.expect(std.mem.indexOf(u8, content, "3.00 process rate") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "96.00 minor + 1.00 major") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "97.00 process rate") != null);}test "page renders exact workload acquisition context" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    var html = Html{ .allocator = allocator };    try workloadAcquisitionMetadata(&html, allocator, .{ .blocked = .{        .position = 3,        .workload_count = 4,        .predecessors = &.{ "a", "b" },    } });    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "acquisition position") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "3 of 4") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "a → b") != null);    try std.testing.expectEqualStrings(        "blocked 3/4 after [a, b]",        try acquisitionLabel(allocator, .{ .blocked = .{            .position = 3,            .workload_count = 4,            .predecessors = &.{ "a", "b" },        } }),    );}test "page renders exact interleaved acquisition context" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const acquisition = profiling.order.Context{ .random_interleaved = .{        .seed = 42,        .repeat_count = 3,        .workload_count = 2,        .selected_workloads = &.{ "a", "b" },        .positions = &.{ 1, 3, 6 },    } };    var html = Html{ .allocator = allocator };    try workloadAcquisitionMetadata(&html, allocator, acquisition);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "random_interleaved") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "xoshiro256") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "interleave seed") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "42") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "a → b") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "1, 3, 6") != null);    try std.testing.expectEqualStrings(        "interleaved 3x/2, positions [1, 3, 6]",        try acquisitionLabel(allocator, acquisition),    );}test "page renders fixed versus random acquisition diagnostic and limits" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const random_acquisition = profiling.order.Context{ .random_interleaved = .{        .seed = 42,        .repeat_count = 3,        .workload_count = 2,        .selected_workloads = &.{ "a", "b" },        .positions = &.{ 1, 3, 6 },    } };    const rows = [_]analysis.OrderEffectRow{.{        .workload = "a",        .fixed_acquisition = .{ .blocked = .{            .position = 1,            .workload_count = 2,        } },        .random_acquisition = random_acquisition,        .fixed_count = 3,        .random_count = 3,        .fixed_mean_ns = 100,        .random_mean_ns = 130,        .mean_percent_change = 30,        .effect_low_percent = 20,        .effect_high_percent = 40,        .classification = "order_sensitive_candidate",    }};    const effects = analysis.OrderEffects{        .support = .{ .state = "supported", .supported = true },        .status = "order_sensitive_candidate",        .fixed_run_id = "fixed",        .random_run_id = "random",        .fixed_is_baseline = true,        .supports_ordersage_test = false,        .reset_policy = "none_recorded",        .effect_method = "bootstrap",        .effect_confidence_per_mille = 950,        .order_sensitive_workloads = 1,        .limits = &.{ "one unreset pair", "absence is not proved" },        .rows = &rows,    };    var html = Html{ .allocator = allocator };    try orderEffectsTable(&html, allocator, effects);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(        u8,        content,        "Fixed vs random acquisition diagnostic",    ) != null);    try std.testing.expect(std.mem.indexOf(u8, content, "order sensitive candidate") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "blocked 1/2") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "positions [1, 3, 6]") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "+30.0%") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "one unreset pair") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "absence is not proved") != null);}test "page renders failed warmup acquisition as not measured" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const rows = [_]analyze.Workload{.{        .name = "w",        .package = "p",        .step = "bench",        .status = "failed",        .exit_code = 9,        .wall_ns = 0,        .total_wall_ns = 0,        .execution_count = 0,        .warmup_count = 1,        .warmup_total_wall_ns = 7,        .warmup_distribution = .{            .kind = .raw_executions,            .sample_count = 1,            .mean_ns = 7,            .min_ns = 7,            .median_ns = 7,            .max_ns = 7,        },        .max_rss_kib = 4,        .user_s = null,        .system_s = null,        .result_path = null,    }};    const entry = model.Entry{        .dir = "run",        .root = "run",        .manifest = .{            .run_id = "run",            .started_unix_ns = 0,            .wall_ns = null,            .suite = "smoke",            .git_sha = null,            .git_branch = null,            .git_dirty = null,            .zig_version = null,            .optimize = null,            .host = .{},        },        .run = .{            .ref = .{                .run_id = "run",                .root = "run",                .manifest_path = "run/manifest.json",                .results_path = "run/results.jsonl",            },            .workloads = &rows,        },        .recorded = null,    };    var table = Html{ .allocator = allocator };    try runWorkloads(&table, allocator, &entry);    const table_content = try table.take();    try std.testing.expect(std.mem.indexOf(u8, table_content, "point estimate") == null);    const content = try workload(        allocator,        .{ .runs = &.{}, .histories = &.{} },        &entry,        &rows[0],        .{},    );    try std.testing.expect(std.mem.indexOf(u8, content, "mean wall</dt><dd>not measured") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "wall sample shape") == null);    try std.testing.expect(std.mem.indexOf(u8, content, "measurement executions</dt><dd>0") != null);}test "page renders matched capture perturbation evidence apart from priority" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const pairs = [_]profiling.perturbation.Pair{        .{ .index = 1, .order = .control_first, .control = .{ .exit_code = 0, .wall_ns = 10 }, .capture = .{ .exit_code = 0, .wall_ns = 11 } },        .{ .index = 2, .order = .capture_first, .control = .{ .exit_code = 0, .wall_ns = 10 }, .capture = .{ .exit_code = 0, .wall_ns = 13 } },    };    const measurement = profiling.perturbation.Measurement{        .state = .complete,        .base_seed = 7,        .workload_seed = 8,        .pairs = &pairs,        .configuration = .{ .tracy = true },        .control_artifacts = .{            .stdout = "",            .stderr = "",            .bench_jsonl = "",            .coz_jsonl = "",            .coz_analysis = "",            .tracy_jsonl = "",            .tracy_summary = "",            .allocations = "",            .structured = "",        },    };    const row = analyze.Workload{        .name = "w",        .package = "p",        .step = "bench",        .status = "passed",        .exit_code = 0,        .wall_ns = 12,        .max_rss_kib = null,        .user_s = null,        .system_s = null,        .result_path = null,        .capture_perturbation = measurement,        .capture_perturbation_summary = try profiling.perturbation.summarize(            allocator,            measurement,            "w",        ),    };    var html = Html{ .allocator = allocator };    try workloadCapturePerturbation(&html, allocator, &row);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "Capture perturbation") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "not product-regression priority evidence") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "95% paired effect") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "active Tracy capture") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "+20.00%") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "control first") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "capture first") != null);}test "page renders explicitly ordered timing samples as a sequence" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const samples = [_]u64{ 30, 10, 20 };    const metrics = [_]profiling.metric.Metric{.{        .workload = "w",        .key = "duration",        .label = "duration",        .source_kind = "bench_jsonl",        .source_path = "bench.jsonl",        .source_line = 1,        .sample_count = 3,        .mean_ns = 20,        .median_ns = 20,        .p75_ns = 30,        .p95_ns = 30,        .p99_ns = 30,        .min_ns = 10,        .max_ns = 30,        .mean_interval = null,        .median_interval = .{ .low_ns = 10, .high_ns = 30 },        .p95_interval = null,        .p99_interval = null,        .samples_ns = &samples,        .sample_sequence = .{ .order = .measured_acquisition_order, .index_origin = 0 },        .distribution = .confidence_interval,    }};    const row = analyze.Workload{        .name = "w",        .package = "p",        .step = "bench",        .status = "passed",        .exit_code = 0,        .wall_ns = 60,        .result_path = null,        .metrics = &metrics,    };    var html = Html{ .allocator = allocator };    try workloadTiming(&html, allocator, .{ .runs = &.{}, .histories = &.{} }, &row);    const content = try html.take();    try std.testing.expect(std.mem.indexOf(u8, content, "chart-sequence-figure") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "sample 0: 30 ns") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "sample 1: 10 ns") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "acquisition indices") != null);    try std.testing.expect(std.mem.indexOf(u8, content, "chart-strip-figure") == null);}test "page run and workload render tables" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    const profiling_dir = ".zig-cache/profile-web-page-run-test";    defer sys.fs.deleteTree(profiling_dir) catch {};    try model.writeTestFixture(allocator, profiling_dir);    const site = try model.load(allocator, profiling_dir);    const entry = site.latest().?;    const run_content = try run(allocator, entry, true);    try std.testing.expect(std.mem.indexOf(u8, run_content, "run-200-bbb") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "memory.html") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "workloads/gpalloc.allocator.html") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "badge-passed") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "cellbar") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "wall samples") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "warmups") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "raw executions") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "process placement") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "CPUs 0-15, memory nodes 0") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "frequency policy") != null);    try std.testing.expect(std.mem.indexOf(u8, run_content, "policy-a") != null);    const workload_row = entry.findWorkload("gpalloc.allocator").?;    const workload_content = try workload(allocator, site, entry, workload_row, try flame.sources(allocator, workload_row));    try std.testing.expect(std.mem.indexOf(u8, workload_content, "Timing metrics") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "1.2 µs") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "Memory metrics") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "4 KiB") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "wall sample shape") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "chart-strip-figure") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "Flame graphs") != null);    try std.testing.expect(std.mem.indexOf(u8, workload_content, "gpalloc.allocator.flame.html#offcpu") != null);    const flame_sources = try flame.sources(allocator, workload_row);    const flame_content = try flamePage(allocator, site, entry, workload_row, flame_sources);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "id=\"cpu\"") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "id=\"offcpu\"") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "data-zw=\"10\"") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "callchain-quality") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "10 extracted · 10 reported") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "3.2 mean · 4 max") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "81.25%") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "6 · 60.00%") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "<script>") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "id=\"cpu-diff\"") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "On-CPU change vs run-100-aaa") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "pp vs baseline") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "Hot symbols") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "88.50%") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "Hot source lines") != null);    try std.testing.expect(std.mem.indexOf(u8, flame_content, "heap.zig:212") != null);    const memory_report = try profiling.report.memory.load(allocator, .{ .input = entry.root, .top = 25 });    try std.testing.expectEqual(@as(usize, 1), memory_report.totals.traced_workloads);    const memory_content = try memoryPage(allocator, entry, memory_report);    try std.testing.expect(std.mem.indexOf(u8, memory_content, "memory accountability") != null);    try std.testing.expect(std.mem.indexOf(u8, memory_content, "root/refill") != null);    try std.testing.expect(std.mem.indexOf(u8, memory_content, "4 KiB") != null);    try std.testing.expect(std.mem.indexOf(u8, memory_content, "coverage") != null);    try std.testing.expect(std.mem.indexOf(u8, memory_content, "integrity complete") != null);}test "flame page explains missing historical callchain quality" {    var arena_state = std.heap.ArenaAllocator.init(std.testing.allocator);    defer arena_state.deinit();    const allocator = arena_state.allocator();    var html = Html{ .allocator = allocator };    try callchainQuality(&html, allocator, .{});    const content = try html.take();    try std.testing.expect(std.mem.indexOf(        u8,        content,        "Callchain quality was not recorded for this capture.",    ) != null);}

Source: src/profiling/report/root.zig:6

zig
pub const page = @import("page.zig");

Complete call list for report.page.flamePage

7 direct calls.

Complete caller list for report.page.run

7 direct callers.

Complete call list for report.page.workload

21 direct calls.

Audit

Definitions10
Public names10
Members0
Version26.7.0
Revisiondaab053ee433