Commit 2291a063 authored by Alexandra's avatar Alexandra

forgot some details

parent 00cbbbde
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var stream = fs.createWriteStream("./results/import_content.csv", {flags:'a'});
fs.truncateSync("./results/import_content.csv");
stream.write("items,time\n");
var to_run = [];
fs.readdir("./files/CONTENT/", function(err, items){
if (err) {
return console.log('Unable to scan directory: ' + err);
}
items.forEach(function (file) {
if (file.includes("zip")) to_run.push({scriptPath : './unit_tests/import_content.js', args : ['-f' ,"./files/CONTENT/"+file], amount : parseInt(file.substring(25, file.length-4))});
});
run(to_run, "./results/import_content.csv", function (err) {if (err) throw err;});
});
...@@ -20,6 +20,7 @@ module.exports = { ...@@ -20,6 +20,7 @@ module.exports = {
var invoked = false, var invoked = false,
to_run = args.shift(); to_run = args.shift();
console.log(to_run.args[1]);
process = childProcess.fork(to_run.scriptPath, to_run.args); process = childProcess.fork(to_run.scriptPath, to_run.args);
process.on('message', function (mes){ process.on('message', function (mes){
......
...@@ -9,9 +9,8 @@ fs.readdir("./files/SITEMAP/", function(err, items){ ...@@ -9,9 +9,8 @@ fs.readdir("./files/SITEMAP/", function(err, items){
if (err) { if (err) {
return console.log('Unable to scan directory: ' + err); return console.log('Unable to scan directory: ' + err);
} }
items.forEach(function (file) {
items.forEach(function (file) { to_run.push({scriptPath : './unit_tests/add_sitemap.js', args : ['-f' ,"./files/SITEMAP/"+file], amount : parseInt(file.substring(25, file.length-4))});
to_run.push({scriptPath : './unit_tests/add_sitemap.js', args : ['-f' ,"./files/SITEMAP/"+file], amount : parseInt(file.substring(25, file.length-4))});
}); });
run(to_run, "./results/sitemap.csv", function (err) {if (err) throw err;}); run(to_run, "./results/sitemap.csv", function (err) {if (err) throw err;});
}); });
...@@ -34,6 +34,7 @@ function init_server (){ ...@@ -34,6 +34,7 @@ function init_server (){
os_utils.cpuUsage(function(v){ os_utils.cpuUsage(function(v){
var ramUsed = v - ramBefore; var ramUsed = v - ramBefore;
process.send(ramUsed + "," + memUsed); process.send(ramUsed + "," + memUsed);
process.send("DONE");
}); });
}); });
browser.close(); browser.close();
......
...@@ -19,6 +19,7 @@ function init_server (){ ...@@ -19,6 +19,7 @@ function init_server (){
if (msg.includes("Done")){ if (msg.includes("Done")){
var now = Date.now(); var now = Date.now();
process.send((now-start)/1000); process.send((now-start)/1000);
process.send("DONE");
ws.close(); ws.close();
browser.close(); browser.close();
} else { } else {
......
...@@ -18,6 +18,7 @@ function init_server (){ ...@@ -18,6 +18,7 @@ function init_server (){
var total = Date.now() - start; var total = Date.now() - start;
//console.log("Time spent : " + total/1000 + "s"); //console.log("Time spent : " + total/1000 + "s");
process.send(total/1000); process.send(total/1000);
process.send("DONE");
// NEED TO SEND SIZE // NEED TO SEND SIZE
} else { } else {
console.log("Error : " + msg); console.log("Error : " + msg);
......
...@@ -22,7 +22,8 @@ function init_server (){ ...@@ -22,7 +22,8 @@ function init_server (){
var total = Date.now() - start; var total = Date.now() - start;
//console.log("Time spent : " + total/1000 + "s"); //console.log("Time spent : " + total/1000 + "s");
process.send(total/1000); process.send(total/1000);
// NEED TO SEND SIZE process.send("DONE");
// NEED TO SEND SIZE
} else { } else {
console.log("Error : " + msg); console.log("Error : " + msg);
browser.close(); browser.close();
......
...@@ -27,6 +27,7 @@ function init_server (){ ...@@ -27,6 +27,7 @@ function init_server (){
} else if (msg === "JSON"){ } else if (msg === "JSON"){
plain = Date.now() - plain_start; plain = Date.now() - plain_start;
process.send(zip/1000 + "," +plain/1000); process.send(zip/1000 + "," +plain/1000);
process.send("DONE");
ws.close(); ws.close();
browser.close(); browser.close();
} else { } else {
......
...@@ -27,6 +27,7 @@ function init_server (){ ...@@ -27,6 +27,7 @@ function init_server (){
} else if (msg === "JSON"){ } else if (msg === "JSON"){
plain = Date.now() - plain_start; plain = Date.now() - plain_start;
process.send(zip/1000 + "," +plain/1000); process.send(zip/1000 + "," +plain/1000);
process.send("DONE");
ws.close(); ws.close();
browser.close(); browser.close();
} else { } else {
......
...@@ -25,6 +25,7 @@ function init_server (){ ...@@ -25,6 +25,7 @@ function init_server (){
if (msg.includes("Done")){ if (msg.includes("Done")){
var time_spent = Date.now() - start; var time_spent = Date.now() - start;
process.send(time_spent/1000); process.send(time_spent/1000);
process.send("DONE");
// console.log(msg + " in " + time_spent/1000 + "s"); // console.log(msg + " in " + time_spent/1000 + "s");
browser.close(); browser.close();
ws.close(); ws.close();
......
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var stream = fs.createWriteStream("./results/import_content.csv", {flags:'a'});
fs.truncateSync("./results/import_content.csv");
stream.write("items,time\n");
var to_run = [{scriptPath : './import_content.js', args : ['-f' ,"./test_files/CONTENT/content100000.zip"], amount : 100000},
{scriptPath : './import_content.js', args : ['-f' ,"./test_files/CONTENT/content10000.zip"], amount : 10000},
{scriptPath : './import_content.js', args : ['-f' ,"./test_files/CONTENT/content1000.zip"], amount : 1000},
{scriptPath : './import_content.js', args : ['-f' ,"./test_files/CONTENT/content100.zip"], amount : 100}];
run(to_run, "./results/import_content.csv", function (err) {if (err) throw err;});
...@@ -22,6 +22,7 @@ function init_server (){ ...@@ -22,6 +22,7 @@ function init_server (){
if (msg.includes("Done : ")){ if (msg.includes("Done : ")){
var time_spent = Date.now() - start; var time_spent = Date.now() - start;
process.send(time_spent/1000); process.send(time_spent/1000);
process.send("DONE");
browser.close(); browser.close();
} else { } else {
console.log("Error : " + msg); console.log("Error : " + msg);
......
...@@ -46,6 +46,7 @@ function init_server (){ ...@@ -46,6 +46,7 @@ function init_server (){
os_utils.cpuUsage(function(v){ os_utils.cpuUsage(function(v){
var ramUsed = v - ramBefore; var ramUsed = v - ramBefore;
process.send(ramUsed + "," + memUsed+ "," + adding_total + "," + saving_total); process.send(ramUsed + "," + memUsed+ "," + adding_total + "," + saving_total);
process.send("DONE");
}); });
}); });
browser.close(); browser.close();
......
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