From 2e9957641e2cd388cbc226596624cb2713caaf63 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Tue, 15 May 2018 23:31:58 -0700 Subject: [PATCH] perf_hooks: always set bootstrapComplete PR-URL: https://github.com/nodejs/node/pull/20768 Reviewed-By: Ruben Bridgewater Reviewed-By: Colin Ihrig --- lib/internal/bootstrap/node.js | 9 +++++++-- test/sequential/test-performance.js | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 51a60bc0d8a344..4d95529c4b58e6 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -157,12 +157,12 @@ // To allow people to extend Node in different ways, this hook allows // one to drop a file lib/_third_party_main.js into the build // directory which will be executed instead of Node's normal loading. + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); process.nextTick(function() { perf.markMilestone(NODE_PERFORMANCE_MILESTONE_THIRD_PARTY_MAIN_START); NativeModule.require('_third_party_main'); perf.markMilestone(NODE_PERFORMANCE_MILESTONE_THIRD_PARTY_MAIN_END); }); - } else if (process.argv[1] === 'inspect' || process.argv[1] === 'debug') { if (process.argv[1] === 'debug') { process.emitWarning( @@ -171,13 +171,14 @@ } // Start the debugger agent. + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); process.nextTick(function() { NativeModule.require('internal/deps/node-inspect/lib/_inspect').start(); }); } else if (process.profProcess) { + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); NativeModule.require('internal/v8_prof_processor'); - } else { // There is user code to be run. @@ -208,6 +209,7 @@ addBuiltinLibsToObject } = NativeModule.require('internal/modules/cjs/helpers'); addBuiltinLibsToObject(global); + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); evalScript('[eval]'); } else if (process.argv[1] && process.argv[1] !== '-') { perf.markMilestone(NODE_PERFORMANCE_MILESTONE_MODULE_LOAD_START); @@ -232,6 +234,7 @@ checkScriptSyntax(source, filename); process.exit(0); } + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); CJSModule.runMain(); } else { perf.markMilestone(NODE_PERFORMANCE_MILESTONE_MODULE_LOAD_START); @@ -262,6 +265,7 @@ if (process._eval != null) { // User passed '-e' or '--eval' + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); evalScript('[eval]'); } } else { @@ -278,6 +282,7 @@ checkScriptSyntax(code, '[stdin]'); } else { process._eval = code; + perf.markMilestone(NODE_PERFORMANCE_MILESTONE_BOOTSTRAP_COMPLETE); evalScript('[stdin]'); } }); diff --git a/test/sequential/test-performance.js b/test/sequential/test-performance.js index c26a7df7616025..c5065227a6a410 100644 --- a/test/sequential/test-performance.js +++ b/test/sequential/test-performance.js @@ -74,7 +74,7 @@ checkNodeTiming({ duration: { around: performance.now() }, nodeStart: { around: 0 }, v8Start: { around: 0 }, - bootstrapComplete: -1, + bootstrapComplete: { around: inited }, environment: { around: 0 }, loopStart: -1, loopExit: -1,