Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 231af88

Browse filesBrowse files
Flarnatargos
authored andcommitted
test: correct test-worker-eventlooputil
The active worker check compared the time from sending message till response arrived from worker with the complete time the worker was running till it responses to the spin request. If sending back the message is slow for some reason the test fails. Adapt the test to compare the time seen inside the worker with the time read from main thread. PR-URL: #35891 Fixes: #35844 Refs: #35886 Refs: #35664 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 76ebae4 commit 231af88
Copy full SHA for 231af88

File tree

Expand file treeCollapse file tree

1 file changed

+8
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+8
-10
lines changed
Open diff view settings
Collapse file

‎test/parallel/test-worker-eventlooputil.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-worker-eventlooputil.js
+8-10Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ function workerOnMetricsMsg(msg) {
3434
}
3535

3636
if (msg.cmd === 'spin') {
37+
const elu = eventLoopUtilization();
3738
const t = now();
3839
while (now() - t < msg.dur);
39-
return this.postMessage(eventLoopUtilization());
40+
return this.postMessage(eventLoopUtilization(elu));
4041
}
4142
}
4243

@@ -50,12 +51,13 @@ let workerELU;
5051
if (eventLoopUtilization().idle <= 0)
5152
return setTimeout(mustCall(r), 5);
5253

54+
mainElu = eventLoopUtilization();
55+
5356
worker = new Worker(__filename, { argv: [ 'iamalive' ] });
5457
metricsCh = new MessageChannel();
5558
worker.postMessage({ metricsCh: metricsCh.port1 }, [ metricsCh.port1 ]);
5659

5760
workerELU = worker.performance.eventLoopUtilization;
58-
mainElu = eventLoopUtilization();
5961
metricsCh.port2.once('message', mustCall(checkWorkerIdle));
6062
metricsCh.port2.postMessage({ cmd: 'elu' });
6163
// Make sure it's still safe to call eventLoopUtilization() after the worker
@@ -66,15 +68,10 @@ let workerELU;
6668
}));
6769
})();
6870

69-
7071
function checkWorkerIdle(wElu) {
71-
const tmpMainElu = eventLoopUtilization(mainElu);
7272
const perfWorkerElu = workerELU();
73-
const eluDiff = eventLoopUtilization(perfWorkerElu, mainElu);
73+
const tmpMainElu = eventLoopUtilization(mainElu);
7474

75-
assert.strictEqual(idleActive(eluDiff),
76-
(perfWorkerElu.active - mainElu.active) +
77-
(perfWorkerElu.idle - mainElu.idle));
7875
assert.ok(idleActive(wElu) > 0, `${idleActive(wElu)} <= 0`);
7976
assert.ok(idleActive(workerELU(wElu)) > 0,
8077
`${idleActive(workerELU(wElu))} <= 0`);
@@ -104,8 +101,9 @@ function checkWorkerActive() {
104101
const w2 = workerELU(w);
105102

106103
assert.ok(w2.active >= 50, `${w2.active} < 50`);
107-
assert.ok(idleActive(wElu) > idleActive(w2),
108-
`${idleActive(wElu)} <= ${idleActive(w2)}`);
104+
assert.ok(wElu.active >= 50, `${wElu.active} < 50`);
105+
assert.ok(idleActive(wElu) < idleActive(w2),
106+
`${idleActive(wElu)} >= ${idleActive(w2)}`);
109107

110108
metricsCh.port2.postMessage({ cmd: 'close' });
111109
});

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.