Skip to content

Commit a3c3213

Browse files
test(html): benchmark a sparse inline-style document
The printer fixtures all run about 12 bytes per `<`, so their columns are sized from markup either way and the sparse pre-size path is never exercised. A 2 MiB critical-CSS `<style>` behind eleven delimiters is the shape the markup probe exists for: 40.39 -> 3.38 ms and 7.667 -> 0 MiB per call under `beautify`.
1 parent 13b4c5d commit a3c3213

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

‎test/benchmarkCases/html-printer-document-unit/index.bench.mjs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,18 @@ const FIXTURES = [
136136
return s;
137137
})(),
138138
{}
139+
],
140+
// Critical CSS inlined into `<head>`: megabytes behind a handful of markup
141+
// delimiters. Every other fixture here runs about 12 bytes per `<`, so this is
142+
// the only one whose columns are sized from length rather than from markup.
143+
[
144+
"sparse inline style",
145+
(() => {
146+
const rule = ".a{color:red;margin:0;padding:0;border:0}\n";
147+
const css = rule.repeat(Math.ceil((2 * 1024 * 1024) / rule.length));
148+
return `<!DOCTYPE html><html><head><style>${css}</style></head><body><p>hello</p></body></html>`;
149+
})(),
150+
{}
139151
]
140152
];
141153

0 commit comments

Comments
 (0)