Commit ac2c2b3a authored by Alexandra Rogova's avatar Alexandra Rogova

debug

parent 0dbf42fd
......@@ -57,10 +57,10 @@ function init_server (){
console.log(msg);
var ramAfter = (os.totalmem() - os.freemem()) / 1024 / 1024;
var ramUsed = ramAfter - ramBefore;
console.log("Ram used : " + ramUsed + " MB");
//console.log("Ram used : " + ramUsed + " MB");
si.mem(function(data){
//process.send(ramUsed + "," + -(data.used / 1024 / 1024 - memBefore));
console.log("Memory used : " + (data.used / 1024 / 1024 - memBefore) + " MB");
process.send(ramUsed + "," + -(data.used / 1024 / 1024 - memBefore));
//console.log("Memory used : " + (data.used / 1024 / 1024 - memBefore) + " MB");
});
browser.close();
});
......@@ -81,6 +81,7 @@ function gen_random_content (){
}
(async () => {
console.log(args.p);
init_server();
var file_path = gen_random_content();
browser = await puppeteer.launch();
......
......@@ -8,42 +8,58 @@ function writeResult(items, info){
}
function runScriptSync(list, callback) {
if (list.length === 0) return;
var invoked = false,
to_run = list.pop();
process = childProcess.fork(to_run.scriptPath, to_run.args);
process.on('message', function (mes){
console.log(to_run.amount + " : " + mes)
writeResult(to_run.amount, mes);
runScriptSync(list, callback);
});
process.on('error', function (err) {
if (invoked) return;
invoked = true;
callback(err);
});
process.on('exit', function (code) {
if (invoked) return;
invoked = true;
var err = code === 0 ? null : new Error('exit code ' + code);
callback(err);
});
if (list.length === 0) return;
var invoked = false,
to_run = list.pop();
process = childProcess.fork(to_run.scriptPath, to_run.args);
process.on('message', function (mes){
console.log(to_run.amount + " : " + mes)
writeResult(to_run.amount, mes);
runScriptSync(list, callback);
});
process.on('error', function (err) {
if (invoked) return;
invoked = true;
callback(err);
});
process.on('exit', function (code) {
if (invoked) return;
invoked = true;
var err = code === 0 ? null : new Error('exit code ' + code);
callback(err);
});
setTimeout(() => {
stream.write(items + ",Timeout error" + "\n");
process.kill();
return;
}, 7200000); //2 hours
setTimeout(() => {
writeResult(to_run.amout, "Timeout error");
process.kill();
return;
}, 7200000); //2 hours
}
fs.truncateSync("./results/add_random_csv_attachment.csv");
stream.write("items,ramUsed,memUsed\n");
var to_run = [{scriptPath : './add_random_csv.js', args : ["-p", 100000, "-s", "attachment"], amount : 100000},
{scriptPath : './add_random_csv.js', args : ["-p", 50000, "-s", "attachment"], amount : 50000},
{scriptPath : './add_random_csv.js', args : ["-p", 10000, "-s", "attachment"], amount : 10000},
{scriptPath : './add_random_csv.js', args : ["-p", 5000, "-s", "attachment"], amount : 5000},
{scriptPath : './add_random_csv.js', args : ["-p", 1000, "-s", "attachment"], amount : 1000},
{scriptPath : './add_random_csv.js', args : ["-p", 100, "-s", "attachment"], amount : 100}];
var to_run = [];
for(var i = 1000000; i > 0; i-=1000){
to_run.push({scriptPath : './add_random_csv.js', args : ["-p", i, "-s", "attachment"], amount : i});
}
// var to_run = [{scriptPath : './add_random_csv.js', args : ["-p", 100000, "-s", "attachment"], amount : 100000},
// {scriptPath : './add_random_csv.js', args : ["-p", 425000, "-s", "attachment"], amount : 425000},
// {scriptPath : './add_random_csv.js', args : ["-p", 400000, "-s", "attachment"], amount : 400000},
// {scriptPath : './add_random_csv.js', args : ["-p", 350000, "-s", "attachment"], amount : 350000},
// {scriptPath : './add_random_csv.js', args : ["-p", 325000, "-s", "attachment"], amount : 325000},
// {scriptPath : './add_random_csv.js', args : ["-p", 300000, "-s", "attachment"], amount : 300000},
// {scriptPath : './add_random_csv.js', args : ["-p", 250000, "-s", "attachment"], amount : 250000},
// {scriptPath : './add_random_csv.js', args : ["-p", 225000, "-s", "attachment"], amount : 225000},
// {scriptPath : './add_random_csv.js', args : ["-p", 200000, "-s", "attachment"], amount : 200000},
// {scriptPath : './add_random_csv.js', args : ["-p", 150000, "-s", "attachment"], amount : 150000},
// {scriptPath : './add_random_csv.js', args : ["-p", 125000, "-s", "attachment"], amount : 125000},
// {scriptPath : './add_random_csv.js', args : ["-p", 100000, "-s", "attachment"], amount : 100000},
// {scriptPath : './add_random_csv.js', args : ["-p", 50000, "-s", "attachment"], amount : 50000},
// {scriptPath : './add_random_csv.js', args : ["-p", 10000, "-s", "attachment"], amount : 10000},
// {scriptPath : './add_random_csv.js', args : ["-p", 5000, "-s", "attachment"], amount : 5000},
// {scriptPath : './add_random_csv.js', args : ["-p", 1000, "-s", "attachment"], amount : 1000},
// {scriptPath : './add_random_csv.js', args : ["-p", 100, "-s", "attachment"], amount : 100}];
runScriptSync(to_run, function (err) {if (err) throw err;});
items,ramUsed,memUsed
100,53.3,0
1000,102,0
5000,203.6,0
10000,318.2,75.9
50000,955.9,521.8
100000,1532.1,1258.8
500000,ERROR,ERROR
items,ramUsed,memUsed
100,53.3,0
1000,102,0
5000,203.6,0
10000,318.2,75.9
50000,955.9,521.8
100000,1532.1,1258.8
500000,ERROR,ERROR
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment