Skip to content
Closed
Changes from 2 commits
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
10 changes: 6 additions & 4 deletions test/parallel/test-worker-eventlooputil.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ function workerOnMetricsMsg(msg) {
}

if (msg.cmd === 'spin') {
const elu = eventLoopUtilization();
const t = now();
while (now() - t < msg.dur);
return this.postMessage(eventLoopUtilization());
return this.postMessage(eventLoopUtilization(elu));
Comment thread
Flarna marked this conversation as resolved.
}
}

Expand Down Expand Up @@ -68,8 +69,8 @@ let workerELU;


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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completely remove the eluDiff test. I don't remember what I was thinking when I added this, but the syntax is invalid. The diff between different ELU's is only valid for the same thread. This does a diff between worker and parent.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

We could add worker.threadId into the elu result and throw on mismatch as it is a clear wrong use.


assert.strictEqual(idleActive(eluDiff),
Expand Down Expand Up @@ -104,8 +105,9 @@ function checkWorkerActive() {
const w2 = workerELU(w);

assert.ok(w2.active >= 50, `${w2.active} < 50`);
assert.ok(idleActive(wElu) > idleActive(w2),
`${idleActive(wElu)} <= ${idleActive(w2)}`);
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)}`);
Comment thread
Flarna marked this conversation as resolved.
Outdated

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