xonecas.io
70160
Ce

cel-tui / commit fcd75e5

fix(benchmarks): update color refs to palette slots, refresh results

Benchmark helpers used old named color strings ("red", "cyan", etc.)
that were replaced by numbered palette slots ("color00"–"color15") in
v0.2.0. This caused emitBuffer and several e2e benchmarks to crash
with 'hex.slice' on undefined.

Updated all color references in helpers.ts and refreshed RESULTS.md
with current numbers. No meaningful regressions — all deltas within
normal run-to-run variance (~5%).

xonecas2026-04-05 fcd75e5b0ba84829e4d3abb156487a78383c68c8 parent 5ee3d01

2 files changed

benchmarks/RESULTS.md+59−59
@@ -2,7 +2,7 @@
22
33 **Machine:** 12th Gen Intel Core i9-12900, ~4.4 GHz
44 **Runtime:** Bun 1.3.9 (x64-linux)
5-**Date:** 2026-04-04
5+**Date:** 2026-04-05 (updated from 2026-04-04 baseline)
66
77 ## Ink Comparison (caveat emptor)
88
@@ -23,11 +23,11 @@ The comparison is included as a rough reference point, not a claim of
2323 superiority. Ink solves a broader set of problems; cel-tui trades
2424 features for raw throughput.
2525
26-| What | cel-tui | Ink 6.8.0 | Ratio |
27-| ------------------------------------------ | ---------- | ------------------------------------------------- | ---------- |
28-| **Single render (comparable tree, 80×24)** | **65 µs** | 632 µs (`renderToString`) | **~10×** |
29-| **1,000 re-renders** | **64 ms** | 632 ms (`renderToString`) / 1,462 ms (`rerender`) | **10–23×** |
30-| **Projected 100k re-renders** | **~6.4 s** | ~63 s (`renderToString`) / ~146 s (`rerender`) | **10–23×** |
26+| What | cel-tui | Ink 6.8.0 | Ratio |
27+| ------------------------------------------ | ---------- | ------------------------------------------------- | --------- |
28+| **Single render (comparable tree, 80×24)** | **65 µs** | 632 µs (`renderToString`) | **~10×** |
29+| **1,000 re-renders** | **67 ms** | 632 ms (`renderToString`) / 1,462 ms (`rerender`) | **9–22×** |
30+| **Projected 100k re-renders** | **~6.7 s** | ~63 s (`renderToString`) / ~146 s (`rerender`) | **9–22×** |
3131
3232 The Ink benchmark script we used is a custom `renderToString` loop (see
3333 [How to Reproduce](#how-to-reproduce)), not Ink's own shipped benchmark,
@@ -51,11 +51,11 @@ numbers are included above.
5151 | Input | Time |
5252 | ---------------------------- | -------- |
5353 | ASCII short (5 chars) | 4.1 ns |
54-| ASCII (64 chars) | 40.3 ns |
55-| ASCII long (640 chars) | 398.6 ns |
56-| CJK + emoji (26 graphemes) | 26.8 ns |
57-| Mixed ASCII + CJK (60 chars) | 5.1 ns |
58-| ANSI escape sequences | 2.9 ns |
54+| ASCII (64 chars) | 39.1 ns |
55+| ASCII long (640 chars) | 386.6 ns |
56+| CJK + emoji (26 graphemes) | 26.6 ns |
57+| Mixed ASCII + CJK (60 chars) | 4.9 ns |
58+| ANSI escape sequences | 3.2 ns |
5959 | Empty string | 0.1 ns |
6060
6161 The fast ASCII path dominates — pure ASCII strings bypass grapheme segmentation entirely.
@@ -65,17 +65,17 @@ The fast ASCII path dominates — pure ASCII strings bypass grapheme segmentatio
6565 | Tree | Time |
6666 | ----------------------------- | -------- |
6767 | 10 children (flat) | 1.5 µs |
68-| 100 children (flat) | 11.9 µs |
69-| 1,000 children (flat) | 124.5 µs |
68+| 100 children (flat) | 12.0 µs |
69+| 1,000 children (flat) | 125.1 µs |
7070 | depth=3 breadth=3 (40 nodes) | 3.0 µs |
71-| depth=4 breadth=3 (121 nodes) | 15.3 µs |
71+| depth=4 breadth=3 (121 nodes) | 15.1 µs |
7272 | depth=3 breadth=5 (156 nodes) | 9.5 µs |
73-| 50 styled groups (200 nodes) | 49.9 µs |
73+| 50 styled groups (200 nodes) | 52.6 µs |
7474 | 10 word-wrap paragraphs | 2.6 µs |
75-| 50 word-wrap paragraphs | 12.3 µs |
76-| Ink-comparable tree | 1.6 µs |
77-| App tree (20 messages) | 9.9 µs |
78-| App tree (100 messages) | 37.9 µs |
75+| 50 word-wrap paragraphs | 13.1 µs |
76+| Ink-comparable tree | 1.7 µs |
77+| App tree (20 messages) | 10.1 µs |
78+| App tree (100 messages) | 39.6 µs |
7979
8080 Layout scales linearly with node count (~120 ns/node for flat trees).
8181
@@ -83,18 +83,18 @@ Layout scales linearly with node count (~120 ns/node for flat trees).
8383
8484 | Scenario | Time |
8585 | ----------------------------- | ------ |
86-| 10 children (flat, 120×40) | 95 µs |
87-| 100 children (flat, 120×40) | 195 µs |
88-| 1,000 children (flat, 120×40) | 198 µs |
89-| Nested 121 nodes (120×40) | 185 µs |
90-| 50 styled groups (120×40) | 220 µs |
91-| 200 lines scrollable (120×40) | 198 µs |
92-| 50 word-wrapped paragraphs | 283 µs |
93-| Ink-comparable (80×24) | 46 µs |
94-| App tree 20 msgs (120×40) | 187 µs |
95-| 80×24 (small terminal) | 110 µs |
96-| 120×40 (medium terminal) | 209 µs |
97-| 200×50 (large terminal) | 312 µs |
86+| 10 children (flat, 120×40) | 93 µs |
87+| 100 children (flat, 120×40) | 193 µs |
88+| 1,000 children (flat, 120×40) | 192 µs |
89+| Nested 121 nodes (120×40) | 180 µs |
90+| 50 styled groups (120×40) | 207 µs |
91+| 200 lines scrollable (120×40) | 185 µs |
92+| 50 word-wrapped paragraphs | 286 µs |
93+| Ink-comparable (80×24) | 45 µs |
94+| App tree 20 msgs (120×40) | 208 µs |
95+| 80×24 (small terminal) | 109 µs |
96+| 120×40 (medium terminal) | 196 µs |
97+| 200×50 (large terminal) | 284 µs |
9898
9999 Paint is O(cells), not O(nodes) — 100 vs 1,000 children produce similar times because only visible cells are painted. Cost scales with terminal size.
100100
@@ -102,14 +102,14 @@ Paint is O(cells), not O(nodes) — 100 vs 1,000 children produce similar times
102102
103103 | Operation | Time |
104104 | ---------------------------- | -------- |
105-| Buffer creation 80×24 | 24.2 µs |
106-| Buffer creation 120×40 | 58.6 µs |
107-| Buffer creation 200×50 | 122.2 µs |
108-| emitBuffer 80×24 (full) | 19.3 µs |
109-| emitBuffer 120×40 (full) | 46.8 µs |
110-| emitDiff 80×24 (no changes) | 11.6 µs |
111-| emitDiff 80×24 (partial) | 11.9 µs |
112-| emitDiff 80×24 (full change) | 10.7 µs |
105+| Buffer creation 80×24 | 24.7 µs |
106+| Buffer creation 120×40 | 58.2 µs |
107+| Buffer creation 200×50 | 117.0 µs |
108+| emitBuffer 80×24 (full) | 21.4 µs |
109+| emitBuffer 120×40 (full) | 46.4 µs |
110+| emitDiff 80×24 (no changes) | 11.8 µs |
111+| emitDiff 80×24 (partial) | 11.1 µs |
112+| emitDiff 80×24 (full change) | 11.2 µs |
113113
114114 Differential rendering has near-constant cost regardless of change amount — dominated by the comparison scan over all cells.
115115
@@ -117,36 +117,36 @@ Differential rendering has near-constant cost regardless of change amount — do
117117
118118 | Operation | Time |
119119 | ---------------------------- | ------- |
120-| hitTest flat 100, center | 135 ns |
121-| hitTest nested 121, center | 35 ns |
122-| hitTest app 50 msgs, center | 102 ns |
123-| hitTest miss (out of bounds) | 1.5 ns |
124-| collectFocusable 100 buttons | 1.15 µs |
125-| collectFocusable app tree | 1.03 µs |
120+| hitTest flat 100, center | 145 ns |
121+| hitTest nested 121, center | 41 ns |
122+| hitTest app 50 msgs, center | 108 ns |
123+| hitTest miss (out of bounds) | 7.7 ns |
124+| collectFocusable 100 buttons | 1.13 µs |
125+| collectFocusable app tree | 0.96 µs |
126126
127127 ### Key Parsing
128128
129129 | Input | Time |
130130 | --------------------- | ------ |
131-| Printable char 'a' | <1 ns |
132-| Ctrl+C (0x03) | <1 ns |
133-| Escape | <1 ns |
134-| Arrow up (CSI) | 2.7 ns |
135-| Shift+Tab (CSI Z) | 7.6 ns |
136-| F5 (CSI 15~) | 163 ns |
137-| Backspace (0x7F) | 6.8 ns |
138-| normalizeKey "ctrl+s" | 90 ns |
131+| Printable char 'a' | 15 ns |
132+| Ctrl+C (0x03) | 18 ns |
133+| Escape | ~1 ns |
134+| Arrow up (CSI) | 58 ns |
135+| Shift+Tab (CSI Z) | <1 ns |
136+| F5 (CSI 15~) | 111 ns |
137+| Backspace (0x7F) | 7.1 ns |
138+| normalizeKey "ctrl+s" | 84 ns |
139139
140140 ### End-to-End Pipeline
141141
142142 | Scenario | Time | Renders/sec |
143143 | ------------------------- | ------ | ----------- |
144-| Ink-comparable (80×24) | 65 µs | **15,400** |
145-| Flat 100 lines (80×24) | 153 µs | 6,500 |
146-| App tree 20 msgs (120×40) | 267 µs | 3,700 |
147-| Re-render no-change diff | 61 µs | 16,400 |
148-| Re-render +1 message diff | 252 µs | 3,970 |
149-| 1,000 re-renders batch | 64 ms | 15,600 |
144+| Ink-comparable (80×24) | 67 µs | **14,900** |
145+| Flat 100 lines (80×24) | 152 µs | 6,600 |
146+| App tree 20 msgs (120×40) | 268 µs | 3,700 |
147+| Re-render no-change diff | 61 µs | 16,300 |
148+| Re-render +1 message diff | 248 µs | 4,030 |
149+| 1,000 re-renders batch | 67 ms | 14,800 |
150150
151151 ## Ink Raw Numbers
152152
benchmarks/helpers.ts+15−15
@@ -36,17 +36,17 @@ export function styledTree(n: number): ContainerNode {
3636 const children: Node[] = [];
3737 for (let i = 0; i < n; i++) {
3838 children.push(
39- VStack({ fgColor: "cyan", bgColor: "black", padding: { x: 1 } }, [
40- Text(`Styled line ${i}`, { bold: true, fgColor: "yellow" }),
41- HStack({ fgColor: "white" }, [
39+ VStack({ fgColor: "color06", bgColor: "color00", padding: { x: 1 } }, [
40+ Text(`Styled line ${i}`, { bold: true, fgColor: "color03" }),
41+ HStack({ fgColor: "color07" }, [
4242 Text("left "),
43- Text("right", { fgColor: "green" }),
43+ Text("right", { fgColor: "color02" }),
4444 ]),
4545 ]),
4646 );
4747 }
4848 return VStack(
49- { height: "100%", fgColor: "white", bgColor: "blue" },
49+ { height: "100%", fgColor: "color07", bgColor: "color04" },
5050 children,
5151 );
5252 }
@@ -77,7 +77,7 @@ export function wrappedTextTree(paragraphs: number): ContainerNode {
7777 /** Build a tree resembling the Ink benchmark: styled text, flex layout, word-wrap. */
7878 export function inkComparableTree(): ContainerNode {
7979 return VStack({ padding: { y: 1, x: 1 } }, [
80- Text("Hello World", { underline: true, bold: true, fgColor: "red" }),
80+ Text("Hello World", { underline: true, bold: true, fgColor: "color01" }),
8181 VStack({ width: 60 }, [
8282 Text(
8383 "Cupcake ipsum dolor sit amet candy candy. Sesame snaps cookie I love tootsie roll apple pie bonbon wafer. Caramels sesame snaps icing cotton candy I love cookie sweet roll. I love bonbon sweet.",
@@ -85,11 +85,11 @@ export function inkComparableTree(): ContainerNode {
8585 ),
8686 ]),
8787 VStack({}, [
88- Text("Colors:", { fgColor: "black", bgColor: "white" }),
88+ Text("Colors:", { fgColor: "color00", bgColor: "color07" }),
8989 VStack({ padding: { x: 1 } }, [
90- Text("- Red", { fgColor: "red" }),
91- Text("- Blue", { fgColor: "blue" }),
92- Text("- Green", { fgColor: "green" }),
90+ Text("- Red", { fgColor: "color01" }),
91+ Text("- Blue", { fgColor: "color04" }),
92+ Text("- Green", { fgColor: "color02" }),
9393 ]),
9494 ]),
9595 ]);
@@ -101,19 +101,19 @@ export function appTree(messageCount: number): ContainerNode {
101101 for (let i = 0; i < messageCount; i++) {
102102 messages.push(
103103 VStack({}, [
104- Text(`▶ User message ${i}`, { bold: true, fgColor: "blue" }),
104+ Text(`▶ User message ${i}`, { bold: true, fgColor: "color04" }),
105105 Text(
106106 ` This is the content of message ${i}. It can be quite long and detailed.`,
107107 ),
108108 ]),
109109 );
110110 }
111- return VStack({ height: "100%", fgColor: "white" }, [
111+ return VStack({ height: "100%", fgColor: "color07" }, [
112112 // Header
113113 HStack({ height: 1, padding: { x: 1 } }, [
114114 Text("Agent Chat", { bold: true }),
115115 VStack({ flex: 1 }, []),
116- Text("model: gpt", { fgColor: "brightBlack" }),
116+ Text("model: gpt", { fgColor: "color08" }),
117117 ]),
118118 // Body
119119 VStack(
@@ -123,8 +123,8 @@ export function appTree(messageCount: number): ContainerNode {
123123 // Input bar
124124 HStack({ height: 1, padding: { x: 1 }, gap: 1 }, [
125125 Text("> "),
126- Text("type a message...", { fgColor: "brightBlack" }),
127- HStack({ bgColor: "brightBlack" }, [Text("[Send]", { bold: true })]),
126+ Text("type a message...", { fgColor: "color08" }),
127+ HStack({ bgColor: "color08" }, [Text("[Send]", { bold: true })]),
128128 ]),
129129 ]);
130130 }