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: harden the tick sampling logic #32190

Closed
wants to merge 3 commits into from
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
11 changes: 6 additions & 5 deletions test/sequential/test-worker-prof.js
Expand Up @@ -11,6 +11,7 @@ const { spawnSync } = require('child_process');
// Refs: https://github.com/nodejs/node/issues/24016

if (process.argv[2] === 'child') {
const fs = require('fs');
let files = fs.readdirSync(tmpdir.path);
const plog = files.filter((name) => /\.log$/.test(name))[0];
if (plog === undefined) {
Expand All @@ -19,20 +20,20 @@ if (process.argv[2] === 'child') {
}
const pingpong = `
let counter = 0;
const fs = require('fs');
const { Worker, parentPort } = require('worker_threads');
parentPort.on('message', (m) => {
if (counter++ === 1024)
if (counter++ === 10)
process.exit(0);
parentPort.postMessage(
m.toString().split('').reverse().toString().replace(/,/g, ''));
fs.readFileSync(m.toString()).toString());
bnoordhuis marked this conversation as resolved.
Show resolved Hide resolved
gireeshpunathil marked this conversation as resolved.
Show resolved Hide resolved
});
`;

const { Worker } = require('worker_threads');
const data = 'x'.repeat(1024);
const w = new Worker(pingpong, { eval: true });
w.on('message', (m) => {
w.postMessage(m.toString().split('').reverse().toString().replace(/,/g, ''));
w.postMessage(process.execPath);
});

w.on('exit', common.mustCall(() => {
Expand All @@ -45,7 +46,7 @@ if (process.argv[2] === 'child') {
}
process.exit(0);
}));
w.postMessage(data);
w.postMessage(process.execPath);
} else {
tmpdir.refresh();
const spawnResult = spawnSync(
Expand Down