Open History to see the last commit
1// Timings are diagnostics only; never include them in cacheable size metrics.
2export function createTimings(write = (line) => process.stderr.write(line)) {
3 function record(phase, durationMs, scenario) {
4 write(
5 `[bundle-size:timing] ${JSON.stringify({
6 phase,
7 ...(scenario ? { scenario } : {}),
8 durationMs: Math.round(durationMs * 1000) / 1000,
9 })}\n`,
10 )
11 }
12β
13 return {
14 record,
15 start(phase, scenario) {
16 const started = performance.now()
17 return () => record(phase, performance.now() - started, scenario)
18 },
19 }
20}