Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fixup! test: correct test-worker-eventlooputil
  • Loading branch information
Flarna committed Nov 3, 2020
commit 932350e8330e2b279ba26419322563fddd2bfdc8
10 changes: 3 additions & 7 deletions test/parallel/test-worker-eventlooputil.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,13 @@ let workerELU;
if (eventLoopUtilization().idle <= 0)
return setTimeout(mustCall(r), 5);

mainElu = eventLoopUtilization();

worker = new Worker(__filename, { argv: [ 'iamalive' ] });
metricsCh = new MessageChannel();
worker.postMessage({ metricsCh: metricsCh.port1 }, [ metricsCh.port1 ]);

workerELU = worker.performance.eventLoopUtilization;
mainElu = eventLoopUtilization();
metricsCh.port2.once('message', mustCall(checkWorkerIdle));
metricsCh.port2.postMessage({ cmd: 'elu' });
// Make sure it's still safe to call eventLoopUtilization() after the worker
Expand All @@ -67,15 +68,10 @@ let workerELU;
}));
})();


function checkWorkerIdle(wElu) {
const perfWorkerElu = workerELU();
const tmpMainElu = eventLoopUtilization(mainElu);
const eluDiff = eventLoopUtilization(perfWorkerElu, mainElu);

assert.strictEqual(idleActive(eluDiff),
(perfWorkerElu.active - mainElu.active) +
(perfWorkerElu.idle - mainElu.idle));
assert.ok(idleActive(wElu) > 0, `${idleActive(wElu)} <= 0`);
assert.ok(idleActive(workerELU(wElu)) > 0,
`${idleActive(workerELU(wElu))} <= 0`);
Expand Down Expand Up @@ -107,7 +103,7 @@ function checkWorkerActive() {
assert.ok(w2.active >= 50, `${w2.active} < 50`);
assert.ok(wElu.active >= 50, `${wElu.active} < 50`);
assert.ok(idleActive(wElu) < idleActive(w2),
Comment thread
Flarna marked this conversation as resolved.
`${idleActive(wElu)} => ${idleActive(w2)}`);
`${idleActive(wElu)} >= ${idleActive(w2)}`);

metricsCh.port2.postMessage({ cmd: 'close' });
});
Expand Down