-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
54 lines (39 loc) · 1.24 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// Dependencies
//
const async = require('async');
const util = require('util');
const { exec } = require("child_process");
const MAX_CONCURRENT_JOBS = 3;
//
// Helper funtion to generate a list of commands
//
async function generateCommandsList() {
let commands = [];
let NUM_PROCESSES = 100;
for (var i=0; i < NUM_PROCESSES; i++) {
let randomValue = 1 + Math.floor(Math.random()*10);
commands[i] = "python pyscript.py " + i + " " + randomValue;
}
return commands;
}
async function run() {
const commandsList = await generateCommandsList();
async.eachLimit(commandsList, MAX_CONCURRENT_JOBS, (command, done) => {
let startTime = Date.now();
console.log("START CMD = " + command + "\n");
exec(command, (error, stdout, stderr) => {
if (error) {
console.log("ERROR CMD = " + command);
console.log(error)
}
console.log("OUTPUT CMD = " + command);
console.log(stdout);
console.log("DONE CMD = " + command);
let execTime = Date.now() - startTime;
console.log(" Execution time: " + execTime + "\n");
done();
});
});
}
run();