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

Function runWorkerTest

test/parallel/test-perf-hooks-eventlooputilization.js:98–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96}
97
98function runWorkerTest() {
99 // Use argv to detect whether we're running as a Worker called by this test
100 // vs. this test also being called as a Worker.
101 if (process.argv[2] === 'iamalive') {
102 parentPort.postMessage(JSON.stringify(eventLoopUtilization()));
103 return;
104 }
105
106 const elu1 = eventLoopUtilization();
107 const worker = new Worker(__filename, { argv: [ 'iamalive' ] });
108
109 worker.on('message', mustCall((msg) => {
110 const elu2 = eventLoopUtilization(elu1);
111 const data = JSON.parse(msg);
112
113 assert.ok(elu2.active + elu2.idle > data.active + data.idle,
114 `${elu2.active + elu2.idle} <= ${data.active + data.idle}`);
115 }));
116}

Callers

nothing calls this directly

Calls 6

mustCallFunction · 0.70
parseMethod · 0.65
eventLoopUtilizationFunction · 0.50
postMessageMethod · 0.45
onMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…