Skip to content

Instantly share code, notes, and snippets.

@addaleax
Last active April 3, 2019 16:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save addaleax/e7d6db099ae194a3f56e473c9d4c49a6 to your computer and use it in GitHub Desktop.
Save addaleax/e7d6db099ae194a3f56e473c9d4c49a6 to your computer and use it in GitHub Desktop.
'use strict';
const fs = require('fs').promises;
const child_process = require('child_process');
const kPIDSpace = 100000;
const kSetupParallelism = 100;
async function createUnwritableFile(filename) {
try {
await fs.unlink(filename);
} catch {}
// Mode 0 means no access at all.
await fs.writeFile(filename, '', { mode: 0 });
}
(async function() {
// Saturate /tmp with unwritable files of the name format /tmp/perf-${pid}.map
for (let i = 0; i < kPIDSpace; i += kSetupParallelism) {
const filePromises = [];
for (let j = i; j < i + kSetupParallelism; j++) {
const filename = `/tmp/perf-${j}.map`;
filePromises.push(createUnwritableFile(filename));
}
await Promise.all(filePromises);
}
child_process.execFileSync(process.execPath, ['--perf-basic-prof', '-e', '']);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment