Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: correct test-worker-eventlooputil #35891

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 6 additions & 4 deletions test/parallel/test-worker-eventlooputil.js
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));
Flarna marked this conversation as resolved.
Show resolved Hide 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
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
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),
Flarna marked this conversation as resolved.
Show resolved Hide resolved
`${idleActive(wElu)} => ${idleActive(w2)}`);
Flarna marked this conversation as resolved.
Show resolved Hide resolved

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