Skip to content

Commit 0b99cb1

Browse files
committed
process: add .initialEventLoop
PR-URL: #28941
1 parent 8ba7a2f commit 0b99cb1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/internal/bootstrap/node.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,22 @@ const rawMethods = internalBinding('process_methods');
9292
};
9393
}
9494

95+
{
96+
let perf_hooks;
97+
let initialEventLoop = true;
98+
ObjectDefineProperty(process, 'initialEventLoop', {
99+
enumerable: true,
100+
configurable: false,
101+
get() {
102+
if (initialEventLoop) {
103+
if (!perf_hooks) perf_hooks = require('perf_hooks');
104+
initialEventLoop = perf_hooks.performance.nodeTiming.loopStart < 0;
105+
}
106+
return initialEventLoop;
107+
}
108+
});
109+
}
110+
95111
const credentials = internalBinding('credentials');
96112
if (credentials.implementsPosixCredentials) {
97113
process.getuid = credentials.getuid;

0 commit comments

Comments
 (0)