Skip to content
Open
Changes from all 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
8 changes: 7 additions & 1 deletion test/sequential/test-worker-eventlooputil.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,19 @@ function checkWorkerIdle(wElu) {
}

function checkWorkerActive() {
// Reading the worker's ELU from this thread is not atomic: the worker's idle
// time is read before the current time. If this thread stalls between the
// two reads while the worker is idle, the stall is counted as worker active
// time in `w` and then missing from `w2`. The duration of the call bounds it.
const start = performance.now();
const w = workerELU();
const skew = performance.now() - start;

metricsCh.port2.postMessage({ cmd: 'spin', dur: 50 });
metricsCh.port2.once('message', mustCall((wElu) => {
const w2 = workerELU(w);

assert.ok(w2.active >= 50, `${w2.active} < 50`);
assert.ok(w2.active >= 50 - skew, `${w2.active} < 50 - ${skew}`);
assert.ok(wElu.active >= 50, `${wElu.active} < 50`);
assert.ok(idleActive(wElu) < idleActive(w2),
`${idleActive(wElu)} >= ${idleActive(w2)}`);
Expand Down
Loading