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

Function internalEventLoopUtilization

lib/internal/perf/event_loop_utilization.js:22–55  ·  view source on GitHub ↗
(loopStart, loopIdleTime, util1, util2)

Source from the content-addressed store, hash-verified

20}
21
22function internalEventLoopUtilization(loopStart, loopIdleTime, util1, util2) {
23 if (loopStart <= 0) {
24 return { idle: 0, active: 0, utilization: 0 };
25 }
26
27 if (util2) {
28 const idle = util1.idle - util2.idle;
29 const active = util1.active - util2.active;
30 return { idle, active, utilization: active / (idle + active) };
31 }
32
33 // Using process.hrtime() to get the time from the beginning of the process,
34 // and offset it by the loopStart time (which is also calculated from the
35 // beginning of the process).
36 const now = process.hrtime();
37 const active = now[0] * 1e3 + now[1] / 1e6 - loopStart - loopIdleTime;
38
39 if (!util1) {
40 return {
41 idle: loopIdleTime,
42 active,
43 utilization: active / (loopIdleTime + active),
44 };
45 }
46
47 const idleDelta = loopIdleTime - util1.idle;
48 const activeDelta = active - util1.active;
49 const utilization = activeDelta / (idleDelta + activeDelta);
50 return {
51 idle: idleDelta,
52 active: activeDelta,
53 utilization,
54 };
55}
56
57module.exports = {
58 internalEventLoopUtilization,

Callers 2

eventLoopUtilizationFunction · 0.85
eventLoopUtilizationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…