Created
February 16, 2018 13:00
-
-
Save sillyslux/e79929d5209f81797fb1f57a9c166e4b to your computer and use it in GitHub Desktop.
multiple threads from node stress testing the cpu
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const shell = require('shelljs'); | |
const nexec = cmd => new Promise((resolve, reject) => { | |
shell.exec(cmd, (code, stdout, stderr) => { | |
if(stderr) reject(stderr); | |
if(code) reject(new Error('exit code')); | |
if(stdout) resolve(stdout); | |
reject(new Error('unexpected behaviour')); | |
}) | |
}); | |
Promise.all([ | |
nexec('stress --cpu 1 --timeout 10; echo "stress 10";'), | |
nexec('stress --cpu 1 --timeout 20; echo "stress 20";'), | |
nexec('stress --cpu 1 --timeout 30; echo "stress 30";'), | |
nexec('stress --cpu 1 --timeout 40; echo "stress 40";'), | |
nexec('stress --cpu 1 --timeout 50; echo "stress 50";'), | |
nexec('stress --cpu 1 --timeout 60; echo "stress 60";') | |
]) | |
.then(console.log); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment