Debian Codegraph @

benchmarks/report/page.html

raw
1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>Go JSON Benchmarks</title>
7 <meta name="description" content="The JSON libraries of Go compared doing the same work, measured on GitHub Actions.">
8 <style>
9 :root {
10 --bg: #ffffff; --fg: #1f2328; --muted: #59636e; --line: #d1d9e0; --soft: #f6f8fa; --card: #ffffff;
11 --accent: #0969da; --good: #1a7f37; --warn: #9a6700;
12 --c-std: #8c959f; --c-v2: #57606a; --c-gojson: #0969da; --c-sonic: #e16f24; --c-jsoniter: #1a7f37; --c-segmentio: #8250df;
13 }
14 @media (prefers-color-scheme: dark) {
15 :root:not([data-theme="light"]) {
16 --bg: #0d1117; --fg: #e6edf3; --muted: #9198a1; --line: #3d444d; --soft: #151b23; --card: #0d1117;
17 --accent: #4493f8; --good: #3fb950; --warn: #d29922;
18 --c-std: #8b949e; --c-v2: #b1bac4; --c-gojson: #4493f8; --c-sonic: #f0883e; --c-jsoniter: #3fb950; --c-segmentio: #a371f7;
19 }
20 }
21 :root[data-theme="dark"] {
22 --bg: #0d1117; --fg: #e6edf3; --muted: #9198a1; --line: #3d444d; --soft: #151b23; --card: #0d1117;
23 --accent: #4493f8; --good: #3fb950; --warn: #d29922;
24 --c-std: #8b949e; --c-v2: #b1bac4; --c-gojson: #4493f8; --c-sonic: #f0883e; --c-jsoniter: #3fb950; --c-segmentio: #a371f7;
25 }
26 * { box-sizing: border-box; }
27 body { background: var(--bg); color: var(--fg); font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; margin: 0; }
28 main { max-width: 1200px; margin: 0 auto; padding: 28px 16px 72px; }
29 h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -0.01em; }
30 h2 { font-size: 22px; margin: 44px 0 6px; }
31 h3 { font-size: 16px; margin: 22px 0 8px; }
32 a { color: var(--accent); }
33 p { max-width: 880px; }
34 .muted { color: var(--muted); }
35 .small { font-size: 13px; }
36 .lead { font-size: 17px; color: var(--muted); margin: 4px 0 18px; }
37 .meta { display: flex; flex-wrap: wrap; gap: 6px 22px; font-size: 13.5px; margin: 10px 0 18px; }
38 .meta b { font-weight: 600; }
39 .libs { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0; }
40 .lib { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px 2px 8px; font-size: 13px; text-decoration: none; color: var(--fg); }
41 .lib:hover { border-color: var(--accent); }
42 .dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
43 .lib .v { color: var(--muted); }
44
45 .controls { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding: 10px 0; margin: 20px 0 0; display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
46 .group { display: flex; align-items: center; gap: 6px; }
47 .group > span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
48 .seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
49 .seg button { background: transparent; color: var(--fg); border: 0; border-right: 1px solid var(--line); padding: 5px 12px; font: inherit; font-size: 13.5px; cursor: pointer; }
50 .seg button:last-child { border-right: 0; }
51 .seg button[aria-pressed="true"] { background: var(--soft); color: var(--accent); font-weight: 600; }
52 .seg button:hover { background: var(--soft); }
53 .machine { font-size: 12.5px; color: var(--muted); }
54
55 .category { margin-top: 36px; border-top: 1px solid var(--line); padding-top: 4px; }
56 .category > p { margin: 4px 0; }
57 details.requires { margin: 6px 0 14px; font-size: 13.5px; }
58 details.requires summary { cursor: pointer; color: var(--accent); }
59 details.requires ul { margin: 6px 0; padding-left: 20px; color: var(--muted); }
60
61 .overview { border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px 10px; background: var(--card); }
62 .overview h3 { margin: 0 0 10px; font-size: 14px; color: var(--muted); font-weight: 600; }
63 .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 12px; margin-top: 12px; }
64 .card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 8px; background: var(--card); }
65 .card h4 { margin: 0; font-size: 14px; }
66 .card .sub { font-size: 12px; color: var(--muted); margin: 0 0 8px; }
67
68 .bars { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 5px 10px; align-items: center; }
69 .bars .label { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 260px; }
70 .card .bars { grid-template-columns: minmax(110px, 46%) 1fr; }
71 .card .bars .label { font-size: 12.5px; max-width: none; }
72 .bars .label .dot { margin-right: 6px; vertical-align: -1px; }
73 .bars .label.base { font-weight: 600; }
74 .bars .label.differs { color: var(--muted); }
75 .track { position: relative; height: 20px; }
76 .bar { position: absolute; left: 0; top: 2px; height: 16px; border-radius: 3px; min-width: 2px; }
77 .bar.differs { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,0.55) 0 3px, transparent 3px 7px) !important; opacity: 0.75; }
78 .value { position: absolute; top: 0; font-size: 12.5px; line-height: 20px; white-space: nowrap; font-variant-numeric: tabular-nums; }
79 .value .x { color: var(--muted); margin-left: 4px; }
80 .value .x.good { color: var(--good); }
81 .one { position: absolute; top: -3px; bottom: -3px; width: 0; border-left: 1px dashed var(--muted); opacity: 0.6; }
82 .sep { grid-column: 1 / -1; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--line); padding-top: 4px; margin-top: 2px; }
83 .mark { color: var(--warn); font-weight: 600; }
84
85 .notes { font-size: 13px; color: var(--muted); margin: 10px 0 0; padding-left: 18px; }
86 .notes li { margin: 2px 0; }
87 details.numbers { margin-top: 12px; }
88 details.numbers summary { cursor: pointer; color: var(--accent); font-size: 13.5px; }
89 .scroll { overflow-x: auto; }
90 table { border-collapse: collapse; font-size: 13px; margin: 8px 0; font-variant-numeric: tabular-nums; }
91 th, td { border: 1px solid var(--line); padding: 4px 8px; text-align: right; white-space: nowrap; }
92 th { background: var(--soft); font-weight: 600; }
93 th:first-child, td:first-child { text-align: left; }
94 td.pass { color: var(--good); text-align: center; }
95 td.fail { color: var(--warn); text-align: center; font-weight: 600; }
96 td.na { color: var(--muted); text-align: center; }
97 ul.plain { padding-left: 20px; }
98 ul.plain li { margin: 4px 0; max-width: 880px; }
99 pre { background: var(--soft); padding: 10px 12px; border-radius: 8px; overflow-x: auto; font-size: 13px; }
100 code { background: var(--soft); padding: 1px 5px; border-radius: 4px; font-size: 13px; }
101 .tip { position: fixed; pointer-events: none; background: var(--fg); color: var(--bg); font-size: 12.5px; padding: 6px 8px; border-radius: 6px; max-width: 340px; z-index: 10; display: none; line-height: 1.4; }
102 @media (max-width: 560px) { .grid { grid-template-columns: 1fr; } .bars .label { max-width: 150px; } }
103 </style>
104 </head>
105 <body>
106 <main>
107 <h1>Go JSON Benchmarks</h1>
108 <p class="lead">The JSON libraries of Go, compared doing the same work.</p>
109 <p>Every library is measured on the same machine of GitHub Actions, by turns, in amd64 and arm64. Libraries are compared within categories of behavior, which every run checks: a library which behaves differently from its category is still shown, apart and marked with <span class="mark">†</span>, with what differs.</p>
110 <div class="meta">
111 <span><b>Measured</b> {{.Generated}}</span>
112 <span><b>Go</b> {{.GoVersion}}</span>
113 {{if .Commit}}<span><b>go-json</b> <a href="https://github.com/{{.Repository}}/commit/{{.Commit}}">{{.ShortCommit}}</a></span>{{end}}
114 {{if .RunURL}}<span><a href="{{.RunURL}}">Workflow run</a></span>{{end}}
115 {{if .Source}}<span><a href="{{.Source}}">Source of the benchmarks</a></span>{{end}}
116 <span><a href="#verify">Verify the results</a></span>
117 </div>
118 <div class="libs" id="libs"></div>
119
120 <div class="controls" id="controls">
121 <div class="group"><span>Machine</span><div class="seg" data-key="run"></div></div>
122 <div class="group"><span>Condition</span><div class="seg" data-key="cond"></div></div>
123 <div class="group"><span>Operation</span><div class="seg" data-key="op"></div></div>
124 <div class="group"><span>Metric</span><div class="seg" data-key="metric"></div></div>
125 <div class="machine" id="machine"></div>
126 </div>
127 <p class="muted small" id="condition"></p>
128
129 <div id="categories"></div>
130
131 <h2 id="fairness">Fairness</h2>
132 <ul class="plain">
133 <li><b>The results depend on the CPU.</b> The machines of GitHub Actions are not the same from run to run, and a library may choose its code by the extensions of the instruction set of the CPU, such as AVX-512: segmentio/encoding, for example, decodes several times faster on a CPU with AVX-512 than on one without it, which can change the order of the libraries. The CPU of each run and its extensions are shown with the results; compare the libraries within a run, not the runs with each other.</li>
134 <li><b>Same machine, by turns.</b> Every library of a run is measured on the same machine, by turns, in several rounds, and the median of the rounds is shown, so that a change of the machine during the run affects every library alike. The machines of GitHub Actions differ from run to run, so the results of different runs are not compared.</li>
135 <li><b>Categories of behavior.</b> A library with an option which makes it do less work is not compared with one doing more: the libraries are grouped in categories of what they do, which every run checks on probes, small inputs which tell a behavior apart ( below ). A library which fails a probe its category requires is shown apart, marked with <span class="mark">†</span>.</li>
136 <li><b>Same results.</b> On every payload, a decoded value is compared with the one encoding/json decodes, and an encoded value with encoding/json's output, byte for byte ( as a JSON value where the keys of a map may be in any order ). A result which differs is marked with <span class="mark">‡</span>.</li>
137 <li><b>Same calls.</b> A value is decoded into a new value for each operation, and the encoders encode a pointer to the value. sonic's fastest configuration decodes from a string, as it is at its fastest: the string is made once, outside of the measurement.</li>
138 <li><b>A real program's heap.</b> "With a live heap of 64 MB" is the condition of a real program, which keeps its own data: the GC runs as often for every library. "Without a live heap" favors a library which keeps more memory alive, as the GC then runs less often.</li>
139 </ul>
140 <h3>Probes</h3>
141 <div class="scroll"><table id="probes"></table></div>
142
143 <h2 id="verify">Verify the results</h2>
144 <p>The result files are produced by the workflow of the repository and attested with GitHub Artifact Attestations, which record the repository, the commit and the workflow run which produced them. Download a result file and verify it with the GitHub CLI:</p>
145 <pre id="verify-cmd"></pre>
146 <p id="raw" class="small"></p>
147 {{if .Attestations}}<p class="small">The attestations of the repository: <a href="{{.Attestations}}">{{.Attestations}}</a></p>{{end}}
148 </main>
149 <div class="tip" id="tip"></div>
150 <script>
151 const D = {{.}};
152 (function () {
153 "use strict";
154 const COLORS = {
155 "encoding/json": "var(--c-std)", "encoding/json/v2": "var(--c-v2)", "goccy/go-json": "var(--c-gojson)",
156 "bytedance/sonic": "var(--c-sonic)", "json-iterator/go": "var(--c-jsoniter)", "segmentio/encoding": "var(--c-segmentio)",
157 };
158 const color = (lib) => COLORS[lib] || "var(--muted)";
159 const METRICS = {
160 speed: { title: "Speed", note: "relative to the baseline, higher is faster" },
161 time: { title: "Time", note: "per operation, lower is faster" },
162 bytes: { title: "Memory", note: "allocated per operation, lower is better" },
163 allocs: { title: "Allocations", note: "per operation, lower is better" },
164 };
165 const OPS = { decode: "Decode", encode: "Encode" };
166 const el = (tag, attrs, ...kids) => {
167 const e = document.createElement(tag);
168 for (const [k, v] of Object.entries(attrs || {})) {
169 if (k === "class") e.className = v; else if (k === "style") e.style.cssText = v; else if (k.startsWith("data-")) e.setAttribute(k, v); else e[k] = v;
170 }
171 for (const k of kids.flat()) if (k != null) e.append(k);
172 return e;
173 };
174 const fmtNs = (ns) => ns >= 1e6 ? (ns / 1e6).toFixed(2) + " ms" : ns >= 1e3 ? (ns / 1e3).toFixed(2) + " µs" : Math.round(ns) + " ns";
175 const fmtBytes = (b) => b >= 1 << 20 ? (b / (1 << 20)).toFixed(2) + " MiB" : b >= 1024 ? (b / 1024).toFixed(1) + " KiB" : b + " B";
176 const fmtX = (x) => (x >= 10 ? x.toFixed(1) : x.toFixed(2)) + "×";
177 const configs = Object.fromEntries(D.configs.map((c) => [c.id, c]));
178 const payloads = D.payloads;
179
180 // state, kept in the URL so that a view can be linked to
181 const state = { run: 0, cond: D.conditions[0].id, op: "decode", metric: "speed" };
182 const readHash = () => {
183 const h = new URLSearchParams(location.hash.slice(1));
184 const arch = h.get("machine");
185 const i = D.runs.findIndex((r) => r.arch === arch);
186 if (i >= 0) state.run = i;
187 if (D.conditions.some((c) => c.id === h.get("condition"))) state.cond = h.get("condition");
188 if (OPS[h.get("op")]) state.op = h.get("op");
189 if (METRICS[h.get("metric")]) state.metric = h.get("metric");
190 };
191 const writeHash = () => {
192 const h = new URLSearchParams({ machine: D.runs[state.run].arch, condition: state.cond, op: state.op, metric: state.metric });
193 history.replaceState(null, "", "#" + h.toString());
194 };
195
196 // the libraries
197 const libs = document.getElementById("libs");
198 for (const l of D.libraries) {
199 const href = l.module === "std" ? "https://pkg.go.dev/" + l.name : /^v/.test(l.version) ? "https://pkg.go.dev/" + l.module + "@" + l.version : "https://" + l.module + "/commit/" + l.version;
200 libs.append(el("a", { class: "lib", href }, el("span", { class: "dot", style: "background:" + color(l.name) }), l.name, el("span", { class: "v" }, /^v|^go/.test(l.version) ? l.version : l.version.slice(0, 7))));
201 }
202
203 // the controls
204 const options = {
205 run: D.runs.map((r, i) => [i, r.arch]),
206 cond: D.conditions.map((c) => [c.id, c.title]),
207 op: Object.entries(OPS),
208 metric: Object.entries(METRICS).map(([k, m]) => [k, m.title]),
209 };
210 document.querySelectorAll(".seg").forEach((seg) => {
211 const key = seg.dataset.key;
212 for (const [value, label] of options[key]) {
213 const b = el("button", { type: "button", textContent: label });
214 b.dataset.value = value;
215 b.addEventListener("click", () => { state[key] = key === "run" ? Number(value) : value; update(); });
216 seg.append(b);
217 }
218 });
219
220 // the tooltip
221 const tip = document.getElementById("tip");
222 document.addEventListener("mousemove", (e) => {
223 const t = e.target.closest("[data-tip]");
224 if (!t) { tip.style.display = "none"; return; }
225 tip.textContent = t.dataset.tip;
226 tip.style.display = "block";
227 const x = Math.min(e.clientX + 14, window.innerWidth - tip.offsetWidth - 8);
228 tip.style.left = x + "px";
229 tip.style.top = (e.clientY + 16) + "px";
230 });
231
232 const resultsOf = (run) => {
233 const m = new Map();
234 for (const r of run.results) m.set(r.condition + "|" + r.op + "|" + r.payload + "|" + r.config, r);
235 return (cond, op, payload, config) => m.get(cond + "|" + op + "|" + payload + "|" + config);
236 };
237 const noteOf = (list) => {
238 const m = new Map();
239 for (const e of list || []) m.set(e.op + "|" + e.payload + "|" + e.config, e.reason);
240 return (op, payload, config) => m.get(op + "|" + payload + "|" + config);
241 };
242 const metricOf = (r, base) => {
243 switch (state.metric) {
244 case "speed": return base ? base.nsPerOp / r.nsPerOp : null;
245 case "time": return r.nsPerOp;
246 case "bytes": return r.bytesPerOp;
247 default: return r.allocsPerOp;
248 }
249 };
250 const label = (v, r, base) => {
251 const rel = base ? base.nsPerOp / r.nsPerOp : null;
252 switch (state.metric) {
253 case "speed": return [fmtX(v), fmtNs(r.nsPerOp), rel > 1.005];
254 case "time": return [fmtNs(v), rel ? fmtX(rel) : "", rel > 1.005];
255 case "bytes": return [fmtBytes(v), base && base.bytesPerOp ? fmtX(v / base.bytesPerOp) + " of the baseline" : "", false];
256 default: return [String(v), base && base.allocsPerOp ? fmtX(v / base.allocsPerOp) + " of the baseline" : "", false];
257 }
258 };
259
260 // bars draws the rows of a chart: rows are {config, value, text, sub, good, tip}; the scale is the largest value.
261 const bars = (rows, opts) => {
262 const box = el("div", { class: "bars" });
263 const max = Math.max(...rows.map((r) => r.value || 0), opts.one ? 1 : 0) || 1;
264 let separated = false;
265 for (const r of rows) {
266 const c = configs[r.config];
267 if (r.differs && !separated) {
268 separated = true;
269 box.append(el("div", { class: "sep" }, "Behave differently from the category ( † ): not the same work"));
270 }
271 const lab = el("div", { class: "label" + (r.base ? " base" : "") + (r.differs ? " differs" : ""), title: c.setting },
272 el("span", { class: "dot", style: "background:" + color(c.library) }), c.title + (r.differs ? " †" : ""));
273 const track = el("div", { class: "track" });
274 if (r.value == null) {
275 track.append(el("span", { class: "value muted", style: "left:0" }, r.missing || "not measured"));
276 } else {
277 const scale = opts.scale || 0.78;
278 const w = 100 * r.value / max * scale;
279 const bar = el("div", { class: "bar" + (r.differs ? " differs" : ""), style: "width:" + w + "%;background-color:" + color(c.library) });
280 bar.dataset.tip = r.tip;
281 const val = el("span", { class: "value", style: "left:calc(" + w + "% + 6px)" }, r.text,
282 r.mark ? el("span", { class: "mark" }, " ‡") : null,
283 r.sub ? el("span", { class: "x" + (r.good ? " good" : "") }, r.sub) : null);
284 val.dataset.tip = r.tip;
285 track.append(bar, val);
286 if (opts.one) track.append(el("div", { class: "one", style: "left:" + (100 / max * scale) + "%" }));
287 }
288 box.append(lab, track);
289 }
290 return box;
291 };
292
293 const categories = document.getElementById("categories");
294 const update = () => {
295 writeHash();
296 document.querySelectorAll(".seg").forEach((seg) => {
297 for (const b of seg.children) b.setAttribute("aria-pressed", String(b.dataset.value === String(state[seg.dataset.key])));
298 });
299 const run = D.runs[state.run];
300 const cond = D.conditions.find((c) => c.id === state.cond);
301 const feats = run.features && run.features.length ? run.features.join(", ") : "unknown";
302 const avx512 = run.arch === "amd64" ? (run.features || []).some((f) => f.startsWith("AVX-512")) ? "" : " · no AVX-512" : "";
303 document.getElementById("machine").textContent = run.cpu + " ( " + feats + avx512 + " ) · " + run.goos + "/" + run.arch + " · " + run.rounds + " rounds of " + run.benchTime + ", median";
304 document.getElementById("condition").textContent = cond.title + ": " + cond.description + " " + METRICS[state.metric].title + " is " + METRICS[state.metric].note + ".";
305 const result = resultsOf(run);
306 const difference = noteOf(run.differences);
307 const exclusion = noteOf(run.exclusions);
308 categories.replaceChildren();
309 for (const cat of D.categories) {
310 const cfgs = D.configs.filter((c) => c.category === cat.id && run.results.some((r) => r.config === c.id && r.op === state.op));
311 if (!cfgs.length) continue;
312 // the configurations which behave as the category requires first
313 const differs = (id) => !!run.differs[id];
314 cfgs.sort((a, b) => differs(a.id) - differs(b.id));
315 const sec = el("section", { class: "category" });
316 sec.append(el("h2", {}, cat.title), el("p", {}, cat.description));
317 if (cat.requires && cat.requires.length) {
318 sec.append(el("details", { class: "requires" }, el("summary", {}, "What the category requires, checked on every run"),
319 el("ul", {}, cat.requires.map((d) => el("li", {}, d)))));
320 }
321
322 // overview: the geometric mean over the payloads, relative to the baseline
323 const ov = el("div", { class: "overview" });
324 const lower = state.metric !== "speed" && state.metric !== "time";
325 ov.append(el("h3", {}, OPS[state.op] + " · geometric mean over the payloads · " +
326 (lower ? METRICS[state.metric].title.toLowerCase() + " relative to " + configs[cat.baseline].title + ", lower is better" : "speed relative to " + configs[cat.baseline].title + ", higher is faster")));
327 const ovRows = cfgs.map((c) => {
328 let s = 0, n = 0;
329 for (const p of payloads) {
330 const r = result(state.cond, state.op, p.id, c.id), b = result(state.cond, state.op, p.id, cat.baseline);
331 if (!r || !b) continue;
332 const x = lower ? (state.metric === "bytes" ? r.bytesPerOp / b.bytesPerOp : r.allocsPerOp / b.allocsPerOp) : b.nsPerOp / r.nsPerOp;
333 if (!isFinite(x) || x <= 0) continue;
334 s += Math.log(x); n++;
335 }
336 const v = n ? Math.exp(s / n) : null;
337 return { config: c.id, value: v, text: v ? fmtX(v) : "", base: c.id === cat.baseline, differs: differs(c.id),
338 good: !lower && v > 1.005, tip: c.title + " ( " + c.setting + " ): " + (v ? fmtX(v) : "") + " over " + n + " payloads" };
339 });
340 ov.append(bars(ovRows, { one: true }));
341 sec.append(ov);
342
343 // one chart for each payload
344 const grid = el("div", { class: "grid" });
345 for (const p of payloads) {
346 const base = result(state.cond, state.op, p.id, cat.baseline);
347 const rows = cfgs.map((c) => {
348 const r = result(state.cond, state.op, p.id, c.id);
349 if (!r) return { config: c.id, value: null, missing: exclusion(state.op, p.id, c.id) ? "fails: " + exclusion(state.op, p.id, c.id) : "not measured", differs: differs(c.id) };
350 const v = metricOf(r, base);
351 const [text] = label(v, r, base);
352 const diff = difference(state.op, p.id, c.id);
353 return { config: c.id, value: v, text, base: c.id === cat.baseline, differs: differs(c.id), mark: !!diff,
354 tip: c.title + ": " + fmtNs(r.nsPerOp) + "/op" + (base ? " ( " + fmtX(base.nsPerOp / r.nsPerOp) + " the speed of " + configs[cat.baseline].title + " )" : "") +
355 ", " + fmtBytes(r.bytesPerOp) + "/op, " + r.allocsPerOp + " allocs/op" + (diff ? " · ‡ " + diff : "") };
356 });
357 grid.append(el("div", { class: "card" }, el("h4", {}, p.title), el("p", { class: "sub" }, p.description + " " + fmtBytes(p.bytes) + " of JSON."),
358 bars(rows, { one: state.metric === "speed", scale: 0.62 })));
359 }
360 sec.append(grid);
361
362 // what differs
363 const notes = [];
364 for (const c of cfgs) {
365 if (differs(c.id)) notes.push(el("li", {}, el("span", { class: "mark" }, "† "), c.title + " ( " + c.setting + " ): " +
366 run.differs[c.id].map((f) => f.description.replace(/\.$/, "") + " — " + f.detail).join("; ")));
367 }
368 for (const c of cfgs) {
369 const sk = run.skips[c.id];
370 if (sk && sk.length) notes.push(el("li", {}, c.title + " ( " + c.setting + " ) differs from encoding/json: " +
371 sk.map((f) => f.description.replace(/\.$/, "") + " — " + f.detail).join("; ")));
372 }
373 for (const c of cfgs) for (const p of payloads) {
374 const d = difference(state.op, p.id, c.id);
375 if (d) notes.push(el("li", {}, el("span", { class: "mark" }, "‡ "), c.title + " on " + p.title + ": " + d));
376 }
377 if (notes.length) sec.append(el("ul", { class: "notes" }, notes));
378
379 // the numbers
380 const table = el("table");
381 table.append(el("tr", {}, el("th", {}, "Library"), payloads.map((p) => el("th", {}, p.title))));
382 for (const c of cfgs) {
383 table.append(el("tr", {}, el("td", {}, c.title + (differs(c.id) ? " †" : "")), payloads.map((p) => {
384 const r = result(state.cond, state.op, p.id, c.id);
385 return el("td", {}, r ? fmtNs(r.nsPerOp) + " · " + fmtBytes(r.bytesPerOp) + " · " + r.allocsPerOp : "–");
386 })));
387 }
388 sec.append(el("details", { class: "numbers" }, el("summary", {}, "The numbers ( time · memory · allocations per operation )"), el("div", { class: "scroll" }, table)));
389 categories.append(sec);
390 }
391 };
392
393 // the probes, of the first machine
394 const probes = document.getElementById("probes");
395 const probed = D.configs.filter((c) => D.probes.some((p) => p.results[c.id]));
396 probes.append(el("tr", {}, el("th", {}, "Probe"), probed.map((c) => el("th", { title: c.setting }, c.title, el("br"), el("span", { class: "muted small" }, D.categories.find((k) => k.id === c.category).id)))));
397 for (const p of D.probes) {
398 probes.append(el("tr", {}, el("td", {}, p.description), probed.map((c) => {
399 const r = p.results[c.id];
400 if (!r) return el("td", { class: "na" }, "–");
401 const td = el("td", { class: r.passed ? "pass" : (r.required ? "fail" : "na") }, r.passed ? "✓" : (r.required ? "✗" : "✗ not required"));
402 if (r.detail) td.dataset.tip = r.detail;
403 return td;
404 })));
405 }
406
407 // how to verify
408 document.getElementById("verify-cmd").textContent = D.runs.map((r) => "gh attestation verify " + r.file + " --repo " + (D.repository || "goccy/go-json")).join("\n");
409 const raw = document.getElementById("raw");
410 raw.append("Raw results: ");
411 D.runs.forEach((r, i) => { if (i) raw.append(" · "); raw.append(el("a", { href: r.file }, r.file)); });
412
413 readHash();
414 window.addEventListener("hashchange", () => { readHash(); update(); });
415 update();
416 })();
417 </script>
418 </body>
419 </html>