Skip to content

Commit a348022

Browse files
committed
experiment: isolate dashboard layout into its own process
A/B for the Simulation contamination hypothesis: run dashboard layout alone in a fresh process (fresh term, cold V8) alongside the in-suite render.bench.ts version, to compare run-to-run variance across repeat runs of the same commit.
1 parent 2848084 commit a348022

2 files changed

Lines changed: 88 additions & 1 deletion

File tree

.github/workflows/benchmark.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ jobs:
9696
with:
9797
mode: simulation
9898
# IMPORTANT! deno task bench fails in CI due to incompatible V8 bindings
99-
run: node bench/mod.ts
99+
run: |
100+
node bench/mod.ts
101+
node bench/dashboard.bench.ts
100102
101103
walltime:
102104
name: Run benchmarks (walltime)

bench/dashboard.bench.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { Bench } from "tinybench";
2+
import { withCodSpeed } from "@codspeed/tinybench-plugin";
3+
import { createTerm } from "../term.ts";
4+
import { close, fixed, grow, open, rgba, text } from "../ops.ts";
5+
import type { Op } from "../ops.ts";
6+
7+
let term = await createTerm({ width: 80, height: 24 });
8+
9+
let dashboardOps: Op[] = [
10+
open("root", {
11+
layout: { width: grow(), height: grow(), direction: "ttb" },
12+
}),
13+
open("header", {
14+
layout: {
15+
width: grow(),
16+
height: fixed(3),
17+
padding: { left: 1 },
18+
direction: "ltr",
19+
},
20+
bg: rgba(30, 30, 40),
21+
border: { color: rgba(80, 80, 100), bottom: 1 },
22+
}),
23+
text("Dashboard", { color: rgba(255, 255, 255) }),
24+
close(),
25+
open("body", {
26+
layout: { width: grow(), height: grow(), direction: "ltr" },
27+
}),
28+
open("sidebar", {
29+
layout: {
30+
width: fixed(20),
31+
height: grow(),
32+
direction: "ttb",
33+
padding: { left: 1, top: 1 },
34+
},
35+
bg: rgba(25, 25, 35),
36+
border: { color: rgba(60, 60, 80), right: 1 },
37+
}),
38+
text("Nav 1"),
39+
text("Nav 2"),
40+
text("Nav 3"),
41+
text("Nav 4"),
42+
close(),
43+
open("main", {
44+
layout: {
45+
width: grow(),
46+
height: grow(),
47+
direction: "ttb",
48+
padding: { left: 2, top: 1 },
49+
},
50+
}),
51+
...Array.from({ length: 10 }, (_, i) => [
52+
open(`row-${i}`, {
53+
layout: {
54+
width: grow(),
55+
height: fixed(1),
56+
direction: "ltr",
57+
},
58+
bg: i % 2 === 0 ? rgba(35, 35, 45) : undefined,
59+
}),
60+
text(`Row ${i}: data value ${i * 42}`),
61+
close(),
62+
]).flat(),
63+
close(),
64+
close(),
65+
open("footer", {
66+
layout: {
67+
width: grow(),
68+
height: fixed(1),
69+
padding: { left: 1 },
70+
},
71+
bg: rgba(30, 30, 40),
72+
}),
73+
text("Ready"),
74+
close(),
75+
close(),
76+
];
77+
78+
let bench = withCodSpeed(new Bench());
79+
80+
bench.add("dashboard layout (isolated)", () => {
81+
term.render(dashboardOps);
82+
});
83+
84+
await bench.run();
85+
console.table(bench.table());

0 commit comments

Comments
 (0)