test: add logging to test-worker-memory

To help troubleshoot CI failures, add some logging.

Refs: https://github.com/nodejs/node/issues/23277#issuecomment-428819187

PR-URL: https://github.com/nodejs/node/pull/23418
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
Rich Trott 2018-10-10 22:14:37 -07:00
parent 8da674df49
commit f121ac0dc4

View File

@ -10,6 +10,7 @@ const numWorkers = +process.env.JOBS || require('os').cpus().length;
// Verify that a Worker's memory isn't kept in memory after the thread finishes.
function run(n, done) {
console.log(`run() called with n=${n} (numWorkers=${numWorkers})`);
if (n <= 0)
return done();
const worker = new Worker(
@ -27,6 +28,7 @@ const startStats = process.memoryUsage();
let finished = 0;
for (let i = 0; i < numWorkers; ++i) {
run(60 / numWorkers, () => {
console.log(`done() called (finished=${finished})`);
if (++finished === numWorkers) {
const finishStats = process.memoryUsage();
// A typical value for this ratio would be ~1.15.