MCPcopy Index your code
hub / github.com/nodejs/node / eventLoopUtilization

Function eventLoopUtilization

lib/internal/worker.js:699–721  ·  view source on GitHub ↗
(util1, util2)

Source from the content-addressed store, hash-verified

697}
698
699function eventLoopUtilization(util1, util2) {
700 // TODO(trevnorris): Works to solve the thread-safe read/write issue of
701 // loopTime, but has the drawback that it can't be set until the event loop
702 // has had a chance to turn. So it will be impossible to read the ELU of
703 // a worker thread immediately after it's been created.
704 if (!this[kIsOnline] || !this[kHandle]) {
705 return { idle: 0, active: 0, utilization: 0 };
706 }
707
708 // Cache loopStart, since it's only written to once.
709 if (this[kLoopStartTime] === -1) {
710 this[kLoopStartTime] = this[kHandle].loopStartTime();
711 if (this[kLoopStartTime] === -1)
712 return { idle: 0, active: 0, utilization: 0 };
713 }
714
715 return internalEventLoopUtilization(
716 this[kLoopStartTime],
717 this[kHandle].loopIdleTime(),
718 util1,
719 util2,
720 );
721}
722
723module.exports = {
724 ownsProcessState,

Callers 9

benchELUSimpleFunction · 0.50
benchELUPassedFunction · 0.50
runIdleTimeTestFunction · 0.50
runCalcTestFunction · 0.50
runWorkerTestFunction · 0.50
workerOnMetricsMsgFunction · 0.50
checkWorkerIdleFunction · 0.50

Calls 1

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…