@tenphi/tasty 0.0.0-snapshot.1c5dff6 → 0.0.0-snapshot.1f1c00a

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (331) hide show
  1. package/README.md +377 -238
  2. package/dist/babel-rZcEwPLM.d.ts +82 -0
  3. package/dist/chunks/async-storage-CG5HnUT5.js +20 -0
  4. package/dist/chunks/async-storage-CG5HnUT5.js.map +1 -0
  5. package/dist/chunks/build-config-CL4eRu2z.js +42 -0
  6. package/dist/chunks/build-config-CL4eRu2z.js.map +1 -0
  7. package/dist/chunks/collector-D2ARGT2L.js +208 -0
  8. package/dist/chunks/collector-D2ARGT2L.js.map +1 -0
  9. package/dist/chunks/config-engine-DEmmPPdp.js +272 -0
  10. package/dist/chunks/config-engine-DEmmPPdp.js.map +1 -0
  11. package/dist/chunks/css-definitions-DotDkIXt.js +876 -0
  12. package/dist/chunks/css-definitions-DotDkIXt.js.map +1 -0
  13. package/dist/chunks/css-resources-P7IBUUZs.js +142 -0
  14. package/dist/chunks/css-resources-P7IBUUZs.js.map +1 -0
  15. package/dist/chunks/debug-D8pg9RGI.js +502 -0
  16. package/dist/chunks/debug-D8pg9RGI.js.map +1 -0
  17. package/dist/chunks/dsl-DRhFWQzo.js +1378 -0
  18. package/dist/chunks/dsl-DRhFWQzo.js.map +1 -0
  19. package/dist/chunks/hydration-TRcz5vnk.js +41 -0
  20. package/dist/chunks/hydration-TRcz5vnk.js.map +1 -0
  21. package/dist/chunks/react-runtime-BpxlOTbO.js +562 -0
  22. package/dist/chunks/react-runtime-BpxlOTbO.js.map +1 -0
  23. package/dist/chunks/runtime-engine-CKFXUH-A.js +2416 -0
  24. package/dist/chunks/runtime-engine-CKFXUH-A.js.map +1 -0
  25. package/dist/chunks/runtime-state-BxaLhVdP.js +127 -0
  26. package/dist/chunks/runtime-state-BxaLhVdP.js.map +1 -0
  27. package/dist/{utils/merge-styles.js → chunks/shared-utils-y-HjvPN4.js} +61 -58
  28. package/dist/chunks/shared-utils-y-HjvPN4.js.map +1 -0
  29. package/dist/chunks/style-engine-BBbBuSkT.js +5260 -0
  30. package/dist/chunks/style-engine-BBbBuSkT.js.map +1 -0
  31. package/dist/{zero/extractor.js → chunks/zero-engine-gJrKBRiw.js} +126 -66
  32. package/dist/chunks/zero-engine-gJrKBRiw.js.map +1 -0
  33. package/dist/collector-w4mBj5gd.d.ts +164 -0
  34. package/dist/config-CZWCzBr6.d.ts +1349 -0
  35. package/dist/core/index.d.ts +5 -33
  36. package/dist/core/index.js +9 -26
  37. package/dist/index-G9JuwM9p.d.ts +1920 -0
  38. package/dist/index.d.ts +5 -48
  39. package/dist/index.js +11 -33
  40. package/dist/{utils/merge-styles.d.ts → merge-styles-VXwJ0Frr.d.ts} +3 -4
  41. package/dist/ssr/astro-client.d.ts +1 -0
  42. package/dist/ssr/astro-client.js +6 -0
  43. package/dist/ssr/astro-client.js.map +1 -0
  44. package/dist/ssr/astro-middleware-extract-static.d.ts +10 -0
  45. package/dist/ssr/astro-middleware-extract-static.js +9 -0
  46. package/dist/ssr/astro-middleware-extract-static.js.map +1 -0
  47. package/dist/ssr/astro-middleware-extract.d.ts +10 -0
  48. package/dist/ssr/astro-middleware-extract.js +9 -0
  49. package/dist/ssr/astro-middleware-extract.js.map +1 -0
  50. package/dist/ssr/astro-middleware-static.d.ts +17 -0
  51. package/dist/ssr/astro-middleware-static.js +7 -0
  52. package/dist/ssr/astro-middleware-static.js.map +1 -0
  53. package/dist/ssr/astro-middleware.d.ts +18 -0
  54. package/dist/ssr/astro-middleware.js +7 -0
  55. package/dist/ssr/astro-middleware.js.map +1 -0
  56. package/dist/ssr/astro.d.ts +127 -0
  57. package/dist/ssr/astro.js +221 -0
  58. package/dist/ssr/astro.js.map +1 -0
  59. package/dist/ssr/index.d.ts +36 -0
  60. package/dist/ssr/index.js +10 -0
  61. package/dist/ssr/index.js.map +1 -0
  62. package/dist/ssr/next-config.d.ts +64 -0
  63. package/dist/ssr/next-config.js +128 -0
  64. package/dist/ssr/next-config.js.map +1 -0
  65. package/dist/ssr/next.d.ts +46 -0
  66. package/dist/ssr/next.js +60 -0
  67. package/dist/ssr/next.js.map +1 -0
  68. package/dist/static/index.d.ts +90 -5
  69. package/dist/static/index.js +31 -4
  70. package/dist/static/index.js.map +1 -0
  71. package/dist/static/inject.d.ts +4 -0
  72. package/dist/static/inject.js +17 -0
  73. package/dist/static/inject.js.map +1 -0
  74. package/dist/types-JEY8PVYP.d.ts +1567 -0
  75. package/dist/zero/babel.d.ts +2 -113
  76. package/dist/zero/babel.js +230 -106
  77. package/dist/zero/babel.js.map +1 -1
  78. package/dist/zero/index.d.ts +80 -3
  79. package/dist/zero/index.js +2 -4
  80. package/dist/zero/next.d.ts +57 -33
  81. package/dist/zero/next.js +93 -59
  82. package/dist/zero/next.js.map +1 -1
  83. package/docs/README.md +39 -0
  84. package/docs/adoption.md +323 -0
  85. package/docs/ai-agents.md +250 -0
  86. package/docs/comparison.md +448 -0
  87. package/docs/configuration.md +684 -56
  88. package/docs/debug.md +170 -343
  89. package/docs/design-system.md +455 -0
  90. package/docs/dsl.md +1065 -0
  91. package/docs/getting-started.md +240 -0
  92. package/docs/injector.md +159 -53
  93. package/docs/methodology.md +648 -0
  94. package/docs/migration-v3.md +285 -0
  95. package/docs/pipeline.md +765 -0
  96. package/docs/plugins.md +353 -0
  97. package/docs/react-api.md +683 -0
  98. package/docs/runtime-benchmarks.md +388 -0
  99. package/docs/ssr.md +610 -0
  100. package/docs/styles.md +211 -63
  101. package/docs/tasty-static.md +273 -67
  102. package/package.json +182 -58
  103. package/tasty.config.ts +6 -0
  104. package/dist/_virtual/_rolldown/runtime.js +0 -8
  105. package/dist/chunks/cacheKey.js +0 -70
  106. package/dist/chunks/cacheKey.js.map +0 -1
  107. package/dist/chunks/definitions.d.ts +0 -37
  108. package/dist/chunks/definitions.js +0 -260
  109. package/dist/chunks/definitions.js.map +0 -1
  110. package/dist/chunks/renderChunk.js +0 -61
  111. package/dist/chunks/renderChunk.js.map +0 -1
  112. package/dist/config.d.ts +0 -288
  113. package/dist/config.js +0 -403
  114. package/dist/config.js.map +0 -1
  115. package/dist/debug.d.ts +0 -204
  116. package/dist/debug.js +0 -733
  117. package/dist/debug.js.map +0 -1
  118. package/dist/hooks/useGlobalStyles.d.ts +0 -27
  119. package/dist/hooks/useGlobalStyles.js +0 -56
  120. package/dist/hooks/useGlobalStyles.js.map +0 -1
  121. package/dist/hooks/useKeyframes.d.ts +0 -56
  122. package/dist/hooks/useKeyframes.js +0 -54
  123. package/dist/hooks/useKeyframes.js.map +0 -1
  124. package/dist/hooks/useProperty.d.ts +0 -79
  125. package/dist/hooks/useProperty.js +0 -91
  126. package/dist/hooks/useProperty.js.map +0 -1
  127. package/dist/hooks/useRawCSS.d.ts +0 -53
  128. package/dist/hooks/useRawCSS.js +0 -28
  129. package/dist/hooks/useRawCSS.js.map +0 -1
  130. package/dist/hooks/useStyles.d.ts +0 -40
  131. package/dist/hooks/useStyles.js +0 -169
  132. package/dist/hooks/useStyles.js.map +0 -1
  133. package/dist/injector/index.d.ts +0 -157
  134. package/dist/injector/index.js +0 -154
  135. package/dist/injector/index.js.map +0 -1
  136. package/dist/injector/injector.d.ts +0 -139
  137. package/dist/injector/injector.js +0 -417
  138. package/dist/injector/injector.js.map +0 -1
  139. package/dist/injector/sheet-manager.d.ts +0 -135
  140. package/dist/injector/sheet-manager.js +0 -728
  141. package/dist/injector/sheet-manager.js.map +0 -1
  142. package/dist/injector/types.d.ts +0 -144
  143. package/dist/keyframes/index.js +0 -206
  144. package/dist/keyframes/index.js.map +0 -1
  145. package/dist/parser/classify.js +0 -319
  146. package/dist/parser/classify.js.map +0 -1
  147. package/dist/parser/const.js +0 -33
  148. package/dist/parser/const.js.map +0 -1
  149. package/dist/parser/lru.js +0 -109
  150. package/dist/parser/lru.js.map +0 -1
  151. package/dist/parser/parser.d.ts +0 -25
  152. package/dist/parser/parser.js +0 -116
  153. package/dist/parser/parser.js.map +0 -1
  154. package/dist/parser/tokenizer.js +0 -69
  155. package/dist/parser/tokenizer.js.map +0 -1
  156. package/dist/parser/types.d.ts +0 -51
  157. package/dist/parser/types.js +0 -46
  158. package/dist/parser/types.js.map +0 -1
  159. package/dist/pipeline/conditions.d.ts +0 -134
  160. package/dist/pipeline/conditions.js +0 -406
  161. package/dist/pipeline/conditions.js.map +0 -1
  162. package/dist/pipeline/exclusive.js +0 -231
  163. package/dist/pipeline/exclusive.js.map +0 -1
  164. package/dist/pipeline/index.d.ts +0 -53
  165. package/dist/pipeline/index.js +0 -660
  166. package/dist/pipeline/index.js.map +0 -1
  167. package/dist/pipeline/materialize.js +0 -856
  168. package/dist/pipeline/materialize.js.map +0 -1
  169. package/dist/pipeline/parseStateKey.d.ts +0 -15
  170. package/dist/pipeline/parseStateKey.js +0 -451
  171. package/dist/pipeline/parseStateKey.js.map +0 -1
  172. package/dist/pipeline/simplify.js +0 -516
  173. package/dist/pipeline/simplify.js.map +0 -1
  174. package/dist/pipeline/warnings.js +0 -18
  175. package/dist/pipeline/warnings.js.map +0 -1
  176. package/dist/plugins/okhsl-plugin.d.ts +0 -35
  177. package/dist/plugins/okhsl-plugin.js +0 -371
  178. package/dist/plugins/okhsl-plugin.js.map +0 -1
  179. package/dist/plugins/types.d.ts +0 -69
  180. package/dist/properties/index.js +0 -221
  181. package/dist/properties/index.js.map +0 -1
  182. package/dist/properties/property-type-resolver.d.ts +0 -24
  183. package/dist/properties/property-type-resolver.js +0 -83
  184. package/dist/properties/property-type-resolver.js.map +0 -1
  185. package/dist/states/index.d.ts +0 -49
  186. package/dist/states/index.js +0 -416
  187. package/dist/states/index.js.map +0 -1
  188. package/dist/static/tastyStatic.d.ts +0 -46
  189. package/dist/static/tastyStatic.js +0 -31
  190. package/dist/static/tastyStatic.js.map +0 -1
  191. package/dist/static/types.d.ts +0 -49
  192. package/dist/static/types.js +0 -24
  193. package/dist/static/types.js.map +0 -1
  194. package/dist/styles/align.d.ts +0 -15
  195. package/dist/styles/align.js +0 -14
  196. package/dist/styles/align.js.map +0 -1
  197. package/dist/styles/border.d.ts +0 -25
  198. package/dist/styles/border.js +0 -114
  199. package/dist/styles/border.js.map +0 -1
  200. package/dist/styles/color.d.ts +0 -14
  201. package/dist/styles/color.js +0 -23
  202. package/dist/styles/color.js.map +0 -1
  203. package/dist/styles/createStyle.js +0 -77
  204. package/dist/styles/createStyle.js.map +0 -1
  205. package/dist/styles/dimension.js +0 -97
  206. package/dist/styles/dimension.js.map +0 -1
  207. package/dist/styles/display.d.ts +0 -37
  208. package/dist/styles/display.js +0 -67
  209. package/dist/styles/display.js.map +0 -1
  210. package/dist/styles/fade.d.ts +0 -15
  211. package/dist/styles/fade.js +0 -58
  212. package/dist/styles/fade.js.map +0 -1
  213. package/dist/styles/fill.d.ts +0 -42
  214. package/dist/styles/fill.js +0 -52
  215. package/dist/styles/fill.js.map +0 -1
  216. package/dist/styles/flow.d.ts +0 -16
  217. package/dist/styles/flow.js +0 -12
  218. package/dist/styles/flow.js.map +0 -1
  219. package/dist/styles/gap.d.ts +0 -31
  220. package/dist/styles/gap.js +0 -37
  221. package/dist/styles/gap.js.map +0 -1
  222. package/dist/styles/height.d.ts +0 -17
  223. package/dist/styles/height.js +0 -20
  224. package/dist/styles/height.js.map +0 -1
  225. package/dist/styles/index.d.ts +0 -2
  226. package/dist/styles/index.js +0 -9
  227. package/dist/styles/index.js.map +0 -1
  228. package/dist/styles/inset.d.ts +0 -52
  229. package/dist/styles/inset.js +0 -150
  230. package/dist/styles/inset.js.map +0 -1
  231. package/dist/styles/justify.d.ts +0 -15
  232. package/dist/styles/justify.js +0 -14
  233. package/dist/styles/justify.js.map +0 -1
  234. package/dist/styles/list.d.ts +0 -16
  235. package/dist/styles/list.js +0 -98
  236. package/dist/styles/list.js.map +0 -1
  237. package/dist/styles/margin.d.ts +0 -24
  238. package/dist/styles/margin.js +0 -104
  239. package/dist/styles/margin.js.map +0 -1
  240. package/dist/styles/outline.d.ts +0 -29
  241. package/dist/styles/outline.js +0 -65
  242. package/dist/styles/outline.js.map +0 -1
  243. package/dist/styles/padding.d.ts +0 -24
  244. package/dist/styles/padding.js +0 -104
  245. package/dist/styles/padding.js.map +0 -1
  246. package/dist/styles/predefined.d.ts +0 -73
  247. package/dist/styles/predefined.js +0 -241
  248. package/dist/styles/predefined.js.map +0 -1
  249. package/dist/styles/preset.d.ts +0 -47
  250. package/dist/styles/preset.js +0 -126
  251. package/dist/styles/preset.js.map +0 -1
  252. package/dist/styles/radius.d.ts +0 -14
  253. package/dist/styles/radius.js +0 -51
  254. package/dist/styles/radius.js.map +0 -1
  255. package/dist/styles/scrollbar.d.ts +0 -23
  256. package/dist/styles/scrollbar.js +0 -34
  257. package/dist/styles/scrollbar.js.map +0 -1
  258. package/dist/styles/shadow.d.ts +0 -14
  259. package/dist/styles/shadow.js +0 -24
  260. package/dist/styles/shadow.js.map +0 -1
  261. package/dist/styles/styledScrollbar.d.ts +0 -47
  262. package/dist/styles/styledScrollbar.js +0 -38
  263. package/dist/styles/styledScrollbar.js.map +0 -1
  264. package/dist/styles/transition.d.ts +0 -14
  265. package/dist/styles/transition.js +0 -158
  266. package/dist/styles/transition.js.map +0 -1
  267. package/dist/styles/types.d.ts +0 -498
  268. package/dist/styles/width.d.ts +0 -17
  269. package/dist/styles/width.js +0 -20
  270. package/dist/styles/width.js.map +0 -1
  271. package/dist/tasty.d.ts +0 -982
  272. package/dist/tasty.js +0 -206
  273. package/dist/tasty.js.map +0 -1
  274. package/dist/tokens/typography.d.ts +0 -19
  275. package/dist/tokens/typography.js +0 -237
  276. package/dist/tokens/typography.js.map +0 -1
  277. package/dist/types.d.ts +0 -184
  278. package/dist/utils/cache-wrapper.js +0 -26
  279. package/dist/utils/cache-wrapper.js.map +0 -1
  280. package/dist/utils/case-converter.js +0 -8
  281. package/dist/utils/case-converter.js.map +0 -1
  282. package/dist/utils/colors.d.ts +0 -5
  283. package/dist/utils/colors.js +0 -9
  284. package/dist/utils/colors.js.map +0 -1
  285. package/dist/utils/css-types.d.ts +0 -7
  286. package/dist/utils/dotize.d.ts +0 -26
  287. package/dist/utils/dotize.js +0 -122
  288. package/dist/utils/dotize.js.map +0 -1
  289. package/dist/utils/filter-base-props.d.ts +0 -15
  290. package/dist/utils/filter-base-props.js +0 -45
  291. package/dist/utils/filter-base-props.js.map +0 -1
  292. package/dist/utils/get-display-name.d.ts +0 -7
  293. package/dist/utils/get-display-name.js +0 -10
  294. package/dist/utils/get-display-name.js.map +0 -1
  295. package/dist/utils/hsl-to-rgb.js +0 -38
  296. package/dist/utils/hsl-to-rgb.js.map +0 -1
  297. package/dist/utils/is-dev-env.js +0 -19
  298. package/dist/utils/is-dev-env.js.map +0 -1
  299. package/dist/utils/is-valid-element-type.js +0 -15
  300. package/dist/utils/is-valid-element-type.js.map +0 -1
  301. package/dist/utils/merge-styles.js.map +0 -1
  302. package/dist/utils/mod-attrs.d.ts +0 -8
  303. package/dist/utils/mod-attrs.js +0 -21
  304. package/dist/utils/mod-attrs.js.map +0 -1
  305. package/dist/utils/okhsl-to-rgb.js +0 -296
  306. package/dist/utils/okhsl-to-rgb.js.map +0 -1
  307. package/dist/utils/process-tokens.d.ts +0 -31
  308. package/dist/utils/process-tokens.js +0 -171
  309. package/dist/utils/process-tokens.js.map +0 -1
  310. package/dist/utils/resolve-recipes.d.ts +0 -17
  311. package/dist/utils/resolve-recipes.js +0 -147
  312. package/dist/utils/resolve-recipes.js.map +0 -1
  313. package/dist/utils/selector-transform.js +0 -32
  314. package/dist/utils/selector-transform.js.map +0 -1
  315. package/dist/utils/string.js +0 -8
  316. package/dist/utils/string.js.map +0 -1
  317. package/dist/utils/styles.d.ts +0 -177
  318. package/dist/utils/styles.js +0 -730
  319. package/dist/utils/styles.js.map +0 -1
  320. package/dist/utils/typography.d.ts +0 -36
  321. package/dist/utils/typography.js +0 -53
  322. package/dist/utils/typography.js.map +0 -1
  323. package/dist/utils/warnings.d.ts +0 -16
  324. package/dist/utils/warnings.js +0 -16
  325. package/dist/utils/warnings.js.map +0 -1
  326. package/dist/zero/css-writer.d.ts +0 -45
  327. package/dist/zero/css-writer.js +0 -74
  328. package/dist/zero/css-writer.js.map +0 -1
  329. package/dist/zero/extractor.d.ts +0 -24
  330. package/dist/zero/extractor.js.map +0 -1
  331. package/docs/usage.md +0 -695
@@ -0,0 +1,388 @@
1
+ # Runtime Benchmarks
2
+
3
+ Tasty keeps its performance claims in reproducible benchmarks rather than
4
+ combining unlike measurements into one score. The repository measures five
5
+ different costs:
6
+
7
+ 1. Style parsing and generation in Node.
8
+ 2. The React overhead of an empty `tasty({})` wrapper.
9
+ 3. Cold browser generation and injection compared with equivalent CSS that is
10
+ already on the page.
11
+ 4. The steady-state interaction path — mod flips and styled subtrees opening
12
+ and closing after the page has loaded.
13
+ 5. Page-load cold start: network, module compilation, execution and first
14
+ paint, end to end in a throttled browser.
15
+
16
+ The first four are focused microbenchmarks, not page-level scores. The fifth is
17
+ a page-level measurement and is the only one that answers "what does a visitor
18
+ wait for". Run them several times on an otherwise idle machine and use a
19
+ production profile to decide whether any cost matters in an application.
20
+
21
+ ## Reproducing the Results
22
+
23
+ ```bash
24
+ pnpm bench
25
+ pnpm bench:overhead
26
+ pnpm bench:injection
27
+ pnpm bench:interaction
28
+ pnpm bench:cold-start
29
+ ```
30
+
31
+ `pnpm bench` runs the core pipeline benchmarks in Node. The rest use production
32
+ code paths in headless Chromium. The first checkout may require
33
+ `pnpm test:setup` to download Chromium, and `pnpm bench:cold-start` needs a
34
+ current `dist/` — run `pnpm build` first.
35
+
36
+ Run the Node and browser suites separately so they do not compete for CPU. The
37
+ browser timer has 0.1 ms resolution, so the browser benchmarks perform many
38
+ matched operations per sample and divide the absolute difference by the number
39
+ of elements, rules or interactions. Machine load, browser versions, and CPU
40
+ power will move the results — on a loaded machine the absolute columns drift
41
+ several percent while the raw/Tasty delta holds, so read the delta.
42
+
43
+ **On a laptop, check the power state first.** Low Power Mode caps CPU frequency,
44
+ and it is the single largest source of error here — larger than background load.
45
+ Measured on the machine below, running on battery with Low Power Mode enabled
46
+ made every one of the 53 Node cases slower, by a median of 26%, and halving the
47
+ background load recovered only 3 points of that. A frequency cap scales every
48
+ case by roughly the same factor, so it does not look like noise; it looks like a
49
+ uniformly slower library. Verify before trusting a run:
50
+
51
+ ```bash
52
+ pmset -g ps | head -2 # want 'AC Power'
53
+ pmset -g | grep -i lowpowermode # want 0
54
+ ```
55
+
56
+ ## Core Style Pipeline
57
+
58
+ Single-call throughput, three consecutive runs on an Apple M3 Pro with Node
59
+ 24.18.0 on AC power:
60
+
61
+ | Operation | ops/sec | Latency (mean) |
62
+ | ----------------------------------------------------------- | --------------------: | -------------: |
63
+ | `renderStyles` — 5 flat properties (cold) | 143,000–158,000 | 6.3–7.0 us |
64
+ | `renderStyles` — state map with media/hover/modifier (cold) | 31,000–36,000 | 28–32 us |
65
+ | `renderStyles` — OR state map across contexts (cold) | 13,000–14,000 | 71–76 us |
66
+ | `renderStyles` — same styles (cached) | 9,830,000–10,420,000 | ~0.10 us |
67
+ | `parseStateKey` — simple key like `:hover` (cold) | 1,910,000–1,980,000 | ~0.50 us |
68
+ | `parseStateKey` — value modifier key (cold) | 1,120,000–1,160,000 | ~0.90 us |
69
+ | `parseStateKey` — complex OR/AND/NOT key (cold) | 341,000–357,000 | 2.8–2.9 us |
70
+ | `parseStateKey` — any key (cached) | 4,900,000–16,530,000 | 0.10–0.20 us |
71
+ | `parseStyle` — value tokens like `2x 4x` (cold) | 575,000–605,000 | ~1.7 us |
72
+ | `parseStyle` — color tokens (cold) | 1,160,000–1,240,000 | 0.80–0.90 us |
73
+ | `parseStyle` — layered functions (cold) | 175,000–184,000 | 5.4–5.7 us |
74
+ | `parseStyle` — any value (cached) | 29,500,000–30,750,000 | ~0.03 us |
75
+
76
+ “Cold” cases use unique inputs to bypass the relevant caches. Cached cases
77
+ reuse one input and measure the LRU hot path. Run-to-run spread on an idle
78
+ machine was 1–7% for most cases, rising to 10–16% for the two `renderStyles`
79
+ cold cases. These benchmarks do not include React, DOM work, stylesheet
80
+ injection, style resolution, layout, or paint.
81
+
82
+ The benchmark sources are colocated with the code they exercise:
83
+ [`pipeline.bench.ts`](../src/pipeline/pipeline.bench.ts),
84
+ [`parseStateKey.bench.ts`](../src/pipeline/parseStateKey.bench.ts), and the
85
+ parser benchmark files under [`src/parser`](../src/parser).
86
+
87
+ ## Empty Wrapper Overhead
88
+
89
+ Skipping the style pipeline does not make a `tasty()` component free. Even
90
+ `tasty({})` is a React component between its parent and the host element. React
91
+ tracks another fiber, and Tasty still processes and forwards the element's
92
+ props.
93
+
94
+ [`tasty-overhead.bench.tsx`](../src/tasty-overhead.bench.tsx) compares 10,000
95
+ raw `<div className>` siblings with 10,000 instances of one module-scoped
96
+ `tasty({})` component. Both receive the same props, and the benchmark fails if
97
+ they do not produce equivalent DOM.
98
+
99
+ The benchmark uses production React in headless Chromium. The factory is
100
+ created and its empty class-name cache is warmed before timing, so factory
101
+ creation, style generation, and injection are excluded. A detached container
102
+ excludes layout, paint, and stylesheet matching. Every commit is wrapped in
103
+ `flushSync`, keeping its synchronous reconciliation and commit inside the
104
+ sample. This does not estimate React's concurrent scheduling latency.
105
+
106
+ On an Apple M3 Pro with React 19.2.8 and Chromium 151, three consecutive runs
107
+ produced these ranges:
108
+
109
+ | Work on 10,000 siblings | Raw elements | `tasty({})` | Extra per wrapped element |
110
+ | ----------------------------------- | -----------: | ----------: | ------------------------: |
111
+ | Mount + remove | 4.2–4.3 ms | 9.2–9.7 ms | 0.50–0.54 us |
112
+ | Rerender, same host props | 1.2–1.3 ms | 6.3–6.5 ms | 0.51–0.52 us |
113
+ | Rerender, change one host attribute | 2.5–2.7 ms | 11.2–11.6 ms | 0.86–0.91 us |
114
+
115
+ The useful result is the raw/Tasty time difference divided by 10,000, not the
116
+ ratio between the two times. The ratio becomes large because the raw baseline
117
+ is tiny. In this synthetic workload, an empty wrapper adds roughly 0.5 us per
118
+ participating element, or ~0.9 us when React also changes a DOM attribute.
119
+
120
+ This is the floor Tasty consumes when it has no styling job. It is not a
121
+ page-level score. Real trees include application components, effects, layout,
122
+ paint, and usually far fewer simultaneous styled-element updates. The benchmark
123
+ also does not measure retained memory; that requires a matched-tree heap
124
+ snapshot experiment with controlled garbage collection.
125
+
126
+ ## Cold Generation and Injection
127
+
128
+ [`tasty-injection.bench.ts`](../src/tasty-injection.bench.ts) measures the extra
129
+ work when Tasty must generate and inject CSS that an otherwise equivalent page
130
+ already has. It does not compare different stylesheet insertion techniques.
131
+
132
+ The benchmark covers two useful workloads:
133
+
134
+ - **One new rule:** add one rule to an existing stylesheet, append its one
135
+ element, and immediately read its computed style. Each timed sample performs
136
+ 50 independent one-rule transactions and reports their total; dividing the
137
+ raw/Tasty difference by 50 produces a stable per-rule result despite
138
+ Chromium's 0.1 ms timer resolution.
139
+ - **1,000 new rules together:** generate and insert all 1,000 rules into one
140
+ stylesheet, append all 1,000 elements, then read every computed color without
141
+ another write in between. This gives the browser one style-resolution
142
+ boundary for the group.
143
+
144
+ For every transaction, the existing-CSS control has the equivalent stylesheet
145
+ parsed, adopted, and attached before timing. The runtime root has a Tasty
146
+ stylesheet pre-created with an unrelated sentinel rule, but not the measured
147
+ rules. Both paths perform the same class assignment, DOM commit, and
148
+ computed-style reads. Only the runtime path calls `computeStyles()` and inserts
149
+ the new rules.
150
+
151
+ Preparation and cleanup happen outside the sample timer. Every runtime style
152
+ value is unique within a cycle, the relevant caches are cleared between cycles,
153
+ and a guard verifies that both paths resolve to the same color. React and the
154
+ `tasty()` wrapper are absent so their independently measured costs do not enter
155
+ the result. Pre-creating both stylesheets also excludes one-time sheet creation
156
+ and adoption from the subtraction.
157
+
158
+ On an Apple M3 Pro with Chromium 151, three consecutive runs produced these
159
+ ranges:
160
+
161
+ | Workload | CSS already present | Tasty runtime | Incremental Tasty cost |
162
+ | ---------------------------------------------------- | ------------------: | -------------: | ---------------------: |
163
+ | One new rule + immediate resolution, per transaction | 2.6–3.0 us | 102.8–107.0 us | 100.3–104.3 us |
164
+ | 1,000 new rules + one resolution | 1.69–1.79 ms | 7.42–7.67 ms | 5.73–5.94 ms |
165
+ | 1,000-rule workload, incremental cost per rule | — | — | 5.7–5.9 us |
166
+
167
+ Directly compared, injecting 1,000 rules before one resolution boundary cost
168
+ about 55–59 times as much in total as injecting one rule and resolving it—not
169
+ 1,000 times as much. Its average incremental cost per rule was about 17–18
170
+ times lower. This is the same Tasty generation and injection path in both cases;
171
+ the group amortizes fixed transaction work and lets the browser resolve all the
172
+ stylesheet writes together.
173
+
174
+ The per-transaction single-rule figure is the one number here that engine work
175
+ does not move: it is dominated by the browser's injection-to-resolution
176
+ boundary, which is crossed once per rule regardless of how fast generation is.
177
+ The 1,000-rule column, where Tasty's own generation dominates, is where engine
178
+ changes show up.
179
+
180
+ The subtraction is the meaningful result. It includes Tasty's cold style
181
+ generation, cache and injector bookkeeping, rule insertion, and any additional
182
+ style invalidation exposed by that workload's resolution boundary. It does not
183
+ pretend to isolate `insertRule()` from the system that calls it.
184
+
185
+ This is a deliberately cold workload. Reused styles resolve from cache and do
186
+ not inject another rule. Different rule complexity, DOM shape, stylesheet size,
187
+ browser, and hardware will change the number. The single-rule and 1,000-rule
188
+ results are not interchangeable: the first crosses the injection-to-resolution
189
+ boundary once per rule, while the second lets the browser resolve 1,000 writes
190
+ together. Because the same resolution pattern is present in each workload's
191
+ control, the difference answers the narrower delivery question: how much extra
192
+ work did Tasty perform when the same CSS was not already there?
193
+
194
+ ## Steady-State Interaction
195
+
196
+ The benchmarks above measure mounting and whole-tree updates. A running
197
+ application spends most of its time on neither. It flips mods — hovered,
198
+ pressed, selected, expanded — on elements whose styles never change, one
199
+ element at a time, and it mounts and unmounts small styled subtrees as menus
200
+ and dialogs open. Both paths go through the state-map and ref-counting
201
+ machinery rather than the parser, so a regression in them is invisible to every
202
+ other benchmark here.
203
+
204
+ [`tasty-interaction.bench.tsx`](../src/tasty-interaction.bench.tsx) pairs each
205
+ case with a raw-DOM equivalent driven by a hand-written stylesheet that
206
+ produces the same computed color and background in both states. The benchmark
207
+ fails if either arm resolves to anything else, so an arm that quietly rendered
208
+ unstyled elements cannot report a flattering number.
209
+
210
+ Each leaf owns its own `useState`, which is what keeps a single-element
211
+ interaction single: re-rendering the root to flip one row would time the whole
212
+ tree. One toggle is far below Chromium's 0.1 ms timer resolution, so a sample
213
+ flips a 100-element tree three times over — 300 commits — and the churn case
214
+ performs 20 open/close cycles. Divide the raw/Tasty difference by those counts.
215
+
216
+ Two things had to be sized deliberately, and both are the difference between a
217
+ readable number and noise:
218
+
219
+ - **The tree is small (100 elements), not large.** React locates a leaf's
220
+ pending update by walking the sibling list, so in a 1,000-element tree a
221
+ single-element update costs ~68 us of traversal — identical in both arms and
222
+ an order of magnitude above anything the styling layer contributes.
223
+ - **The sample resolves style once, not once per flip.** Forcing a recalc
224
+ between flips costs ~70 us in both arms, which buries the delta the same way.
225
+ The browser's side of an interaction is real, but it is the browser's;
226
+ resolution boundaries are what the injection benchmark above measures.
227
+
228
+ The contract check also reads the injected CSS **before** any toggle and fails
229
+ if the hovered rule is not already there. That a style map's states all ship in
230
+ one chunk on first render is the premise of this case; if the hovered rule
231
+ arrived lazily, the first sample would be timing injection.
232
+
233
+ On an Apple M3 Pro with React 19.2.8 and Chromium 151, three consecutive runs:
234
+
235
+ | Workload | Raw elements | Tasty mods | Extra per unit |
236
+ | ---------------------------------------------------- | -----------: | ---------: | -----------------------: |
237
+ | 300 single-element mod toggles in a 100-element tree | 1.7–1.8 ms | 2.0–2.1 ms | 1.2–1.3 us / interaction |
238
+ | 20 mount + unmount cycles of a 200-element subtree | 5.2–5.4 ms | 8.3–8.6 ms | 0.77–0.81 us / element |
239
+
240
+ The absolute columns move several percent with machine load; the delta between
241
+ the arms is the stable quantity, so read that rather than either column.
242
+
243
+ Two things are worth reading out of this.
244
+
245
+ A mod flip on an already-mounted element costs about 1.2 us. The CSS for both
246
+ states already exists — Tasty emits every state of a style map in one chunk on
247
+ first render — so both arms perform the same commit, and what is left is
248
+ Tasty's props and mod handling. That is the same order as the ~0.5 us empty
249
+ wrapper measured above, which is most of where it comes from.
250
+
251
+ Subtree churn is not about styling at all. Its ~0.8 us per element sits right
252
+ on the empty-wrapper mount cost, because the styles are already cached:
253
+ reopening a menu re-pays the React wrapper, not the style pipeline.
254
+
255
+ ## Page-Load Cold Start
256
+
257
+ Every benchmark above deliberately excludes the network, module compilation and
258
+ the first render. [`scripts/cold-start`](../scripts/cold-start) measures exactly
259
+ those: what a visitor waits for between requesting a page and seeing styled
260
+ content, in a real Chromium under CDP network and CPU throttling.
261
+
262
+ Three pages render the same 50 styled components and are verified, before any
263
+ timing, to produce the same 50 elements at the same computed color:
264
+
265
+ - **baseline** — the components server-rendered: identical markup, identical
266
+ class names, a linked stylesheet, and no Tasty on the page. Every other
267
+ column is a delta against this one.
268
+ - **runtime** — Tasty generates the CSS in the browser, as a client-rendered
269
+ application does. The run asserts it really did (69 rules generated).
270
+ - **prewarm** — the same, after one throwaway `computeStyles()` against a
271
+ detached root before the first component renders.
272
+
273
+ Each cell is the median of 5 uncached loads in a fresh browser context. The run
274
+ ends at the first contentful paint, observed through a `PerformanceObserver`
275
+ rather than counted in animation frames — `requestAnimationFrame` fires before
276
+ paint, so a page that commits fast can reach its second frame with nothing
277
+ painted yet.
278
+
279
+ Two things about the payload decide whether this measures a deployment or a
280
+ straw man, so both are enforced rather than assumed:
281
+
282
+ - **Assets are served brotli-compressed**, the way a static host serves them.
283
+ The bundle is 51.5 KB on the wire and 180 KB decoded; putting the decoded
284
+ bytes on a 1.6 Mbps link would add ~700 ms and charge it to Tasty. The run
285
+ reads `encodedBodySize` back out of resource timing and fails if what
286
+ crossed the wire is not the compressed size the table reports.
287
+ - **The bundle is built from what the page imports** (`tasty`, `configure`,
288
+ `computeStyles`, `tastyDebug`), so it is tree-shaken as an application's
289
+ would be. Re-exporting the whole library adds ~4 KB brotli of code no page
290
+ here calls.
291
+
292
+ On an Apple M3 Pro with React 19.2.8 and Chromium 151, first contentful paint,
293
+ median of three full runs of the matrix:
294
+
295
+ | Link / CPU | baseline | runtime | prewarm | Tasty's cost | noise |
296
+ | --------------------- | -------: | ------: | ------: | -----------: | ----: |
297
+ | No throttling, 1x | 36 ms | 40 ms | 40 ms | +4 ms | 0 ms |
298
+ | Fast 4G, 1x | 628 ms | 672 ms | 688 ms | +44 ms | 20 ms |
299
+ | Slow 4G, 1x | 2044 ms | 2308 ms | 2308 ms | +264 ms | 24 ms |
300
+ | No throttling, 4x CPU | 112 ms | 144 ms | 144 ms | +32 ms | 16 ms |
301
+ | Fast 4G, 4x CPU | 656 ms | 728 ms | 736 ms | +72 ms | 4 ms |
302
+ | Slow 4G, 4x CPU | 2064 ms | 2360 ms | 2360 ms | +296 ms | 8 ms |
303
+
304
+ The `noise` column is not an estimate. The `baseline` page contains no Tasty at
305
+ all, so its three samples should be identical; the spread they actually show is
306
+ this cell's measurement error, and it applies to the other columns too.
307
+
308
+ Read that column before any other. Only the Slow 4G rows carry a cost an order
309
+ of magnitude above their own noise. The unthrottled 1x row (+4 ms) means "too
310
+ small to measure this way", not "4 ms". And a single run is genuinely not
311
+ enough here: taken alone, the first of these three runs put Fast 4G 1x at
312
+ +72 ms, which the median over three corrects to +44 ms.
313
+
314
+ For the same reason, `prewarm` landing above `runtime` in the Fast 4G 1x row is
315
+ noise, not a cost — the two modes differ only in when the engine compiles, and
316
+ that difference is measured in the phase table below, not in FCP.
317
+
318
+ **The cost is the bundle, not the work.** On Slow 4G the extra transfer alone
319
+ accounts for 263 ms of the 264 ms FCP delta — effectively all of it. Everything
320
+ Tasty then *does* is small by comparison (median of three runs):
321
+
322
+ | Phase (Slow 4G, 1x) | baseline | runtime | prewarm |
323
+ | ----------------------- | -------: | ------: | ------: |
324
+ | js+css transfer | 1423 ms | 1686 ms | 1690 ms |
325
+ | module compile (shared) | 3.5 ms | 3.3 ms | 3.0 ms |
326
+ | tasty top-level execute | — | 1.2 ms | 0.8 ms |
327
+ | `configure()` | — | 0.6 ms | 0.4 ms |
328
+ | prewarm | — | — | 3.3 ms |
329
+ | render 1st component | 3.0 ms | 7.3 ms | 1.9 ms |
330
+ | render 49 more | 1.3 ms | 5.2 ms | 3.8 ms |
331
+
332
+ Importing Tasty costs about 1 ms of top-level execution; `configure()` costs
333
+ half of one. The rest of the CPU delta — about 10 ms for 50 components — is
334
+ generation and injection, which is the cost the injection benchmark isolates.
335
+
336
+ One asymmetry is worth naming: the control links a render-blocking stylesheet
337
+ and the runtime modes have none, so the control's first paint waits for CSS the
338
+ runtime modes never request. That is the real difference between the two
339
+ delivery models, not a thumb on the scale, but it means the FCP delta is not
340
+ purely "what Tasty costs to execute".
341
+
342
+ **Prewarming moves the wake-up, it does not remove it.** The first styled render
343
+ is ~5.4 ms more expensive than the ones after it, because that is when the
344
+ engine's deferred payload is actually compiled. A throwaway `computeStyles()`
345
+ against a detached root pays it early: `render 1st` drops from 7.3 ms to
346
+ 1.9 ms. The prewarm itself costs 3.3 ms, so the work is moved rather than
347
+ removed and FCP does not move. It is worth doing only when something else can
348
+ overlap it, or when the first render is on a latency-critical path and the page
349
+ has idle time before it.
350
+
351
+ **Retained heap.** After a forced collection, the runtime page holds about
352
+ 985 KB more than the control (2,605 KB vs 1,619 KB) for 50 components — the
353
+ parser caches, the chunk cache, the injector's registry and the generated CSS.
354
+ The control is not zero either; most of its 1.6 MB is React and the DOM.
355
+
356
+ CPU throttling changes which line moves. At 4x, module compilation of the
357
+ larger graph becomes visible (2.6 ms → 19 ms) where at 1x it is free: V8
358
+ pre-parses at import and compiles lazily, so a slower CPU pays for code the
359
+ faster one never fully compiled. Transfer numbers from the unthrottled cells
360
+ are not worth reading — with no emulated link, resource timings are scheduling
361
+ jitter.
362
+
363
+ ## Reading the Results Together
364
+
365
+ Do not add the microbenchmark numbers together to estimate an application
366
+ blindly. They describe different paths:
367
+
368
+ - A stable `tasty()` factory can skip the style pipeline on later renders, but
369
+ its React wrapper still participates in reconciliation.
370
+ - A cached style avoids cold parsing and generation and does not insert a new
371
+ rule.
372
+ - A genuinely new style pays generation and injection once, then becomes
373
+ reusable.
374
+ - A mod flip on an already-styled element pays neither; it is a class-name
375
+ change.
376
+ - Browser style resolution, layout, and paint depend on the actual document and
377
+ need application-level profiling.
378
+
379
+ The cold-start measurement is the one that puts the rest in proportion. On a
380
+ slow connection, nearly all of Tasty's page-load cost is transferring the
381
+ library — 263 ms of a 264 ms delta — while the generation and injection the
382
+ microbenchmarks obsess over is ~10 ms for 50 components. Bundle size is
383
+ therefore the lever with the largest effect on first paint, and the runtime
384
+ levers matter for what happens after it.
385
+
386
+ The practical optimization target is therefore repeated work: keep style input
387
+ stable when possible, reuse generated chunks, and generate CSS at build or
388
+ server time when runtime flexibility is unnecessary.