chore: count built-ins loaded on startup paths · nuxt/cli@579ee5d · GitHub
Skip to content

Commit 579ee5d

Browse files
committed
chore: count built-ins loaded on startup paths
1 parent 97d50f4 commit 579ee5d

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎bench/README.md‎

Lines changed: 1 addition & 1 deletion

‎bench/lib/module-hook.mjs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import module from 'node:module'
22
import process from 'node:process'
33

44
const loaded = new Map()
5+
const bootBuiltins = new Set(process.moduleLoadList)
56

67
module.registerHooks({
78
load(url, context, nextLoad) {
@@ -25,5 +26,6 @@ process.on('exit', () => {
2526
}
2627
}
2728
// `_rawDebug` writes straight to fd 2 and cannot be intercepted by the CLI's own logging
28-
process._rawDebug(`__BENCH_MODULES__${JSON.stringify({ modules: loaded.size, nodeModules, bytes })}`)
29+
const builtins = process.moduleLoadList.filter(entry => entry.startsWith('NativeModule ') && !bootBuiltins.has(entry)).length
30+
process._rawDebug(`__BENCH_MODULES__${JSON.stringify({ modules: loaded.size, nodeModules, bytes, builtins })}`)
2931
})

‎bench/run.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,10 @@ for (const [caseId, label] of STARTUP_CASES) {
149149
const baseline = moduleResults?.find(r => r.case === caseId && r.target === 'baseline')
150150
const head = moduleResults?.find(r => r.case === caseId && r.target === 'head')
151151
if (baseline && head) {
152-
headlineRows.push([`${label} modules loaded`, String(baseline.modules), String(head.modules), formatDelta(baseline.modules, head.modules)])
152+
headlineRows.push(
153+
[`${label} modules loaded`, String(baseline.modules), String(head.modules), formatDelta(baseline.modules, head.modules)],
154+
[`${label} built-ins loaded`, String(baseline.builtins), String(head.builtins), formatDelta(baseline.builtins, head.builtins)],
155+
)
153156
}
154157
}
155158
if (footprintResults) {

‎bench/suites/modules.ts‎

Lines changed: 8 additions & 3 deletions

0 commit comments

Comments
 (0)