Commit a6e13c59 authored by Alexandra Rogova's avatar Alexandra Rogova

major restructure part 2

parent 2e1d402d

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

{
"env": {
"amd" : true,
"node": true,
"es6": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly"
},
"parserOptions": {
"ecmaVersion": 2018,
"sourceType": "module"
},
"rules": {
"indent": [
"error",
4
],
"linebreak-style": [
"error",
"windows"
],
"quotes": [
"error",
"double"
],
"semi": [
"error",
"always"
]
}
}
\ No newline at end of file
{
"node" : true,
"maxlen" : 80,
"indent" : 2,
"maxerr" : 3,
"terse" : true,
"for" : true
}
\ No newline at end of file
const fs = require('fs');
var ipc=require('node-ipc');
const args = require("yargs")
.usage("Usage : Milestone1/all.js -only test -file only on this file -verbose")
.alias("f", "file")
.alias("o", "only")
.alias("v", "verbose")
.describe("file", "If you want to run the test on only one file (as opposed to all files in the directory), add this option and specify file location")
.describe("only", "If you only want to run one test, add this option and specify the test file name (eg : rss_bench)")
.describe("verbose", "Print results to console, if not specified results will only be copied to result file")
.nargs("file", 1)
.nargs("only", 1)
.nargs("verbose", 0)
.argv;
var current;
var to_run = [];
var options = [];
var only_script = args.only == null ? "" : args.only;
if(args.file !== undefined){
options.push("f");
options.push(args.file);
}
if (args.v !== undefined){
options.push("v");
}
ipc.config.id = 'main';
ipc.config.silent = true;
ipc.serve(
function(){
ipc.server.on('message', function(data,socket){
if (args.v) console.log(data);
if (data == "DONE") run(to_run, function (err) {if (err) throw err;});
});
ipc.server.on('socket.disconnected', function(socket, destroyedSocketID) {
ipc.log('client ' + destroyedSocketID + ' has disconnected!');
});
}
);
ipc.server.start();
function run (to_run_array, callback){
var childProcess = require('child_process');
if (to_run_array.length === 0){
return;
}
var invoked = false,
current = to_run_array.shift();
console.log("Starting" + current);
process = childProcess.fork(current, options);
process.on('message', function (mes){});
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);
});
};
fs.readdir("./bench_files/", function(err, items){
if (err) {
return console.log('Unable to scan directory: ' + err);
}
items.forEach(function (file) {
if (!file.includes("run_scripts_sync") && file.includes(only_script)) {
to_run.push("./bench_files/"+file);
}
});
run(to_run, function (err) {if (err) throw err;});
});
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var stream = fs.createWriteStream("./results/add_csv_attachments.csv", {flags:'a'});
fs.truncateSync("./results/add_csv_attachments.csv");
stream.write("items,ramUsed,memUsed\n");
var to_run = [];
fs.readdir("./files/CSV/", function(err, items){
if (err) {
return console.log('Unable to scan directory: ' + err);
}
items.forEach(function (file) {
to_run.push({scriptPath : './unit_tests/add_csv.js', args : ['-f' ,"./files/CSV/"+file, "-s", "attachment"]});
});
to_run.sort(function(file1, file2){
var nb_items_file1 = parseInt(file1.args[1].slice(file1.args[1].indexOf("_")+1, file1.args[1].lastIndexOf(".")));
var nb_items_file2 = parseInt(file2.args[1].slice(file2.args[1].indexOf("_")+1, file2.args[1].lastIndexOf(".")));
return nb_items_file1 - nb_items_file2;
});
run(to_run, "./results/add_csv_attachments.csv", function (err) {if (err) throw err;});
});
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var stream = fs.createWriteStream("../results/add_csv_metadata.csv", {flags:'a'});
fs.truncateSync("../results/add_csv_metadata.csv");
stream.write("items,ramUsed,memUsed\n");
var to_run = [];
fs.readdir("../files/CSV/", function(err, items){
if (err) {
return console.log('Unable to scan directory: ' + err);
}
items.forEach(function (file) {
to_run.push({scriptPath : '../unit_tests/add_csv.js', args : ['-f' ,"../files/CSV/"+file, "-s", "metadata"], amount : parseInt(file.substring(17, file.length-4))});
});
to_run.sort(function(file1, file2){
var nb_items_file1 = parseInt(file1.args[1].slice(file1.args[1].indexOf("_")+1, file1.args[1].lastIndexOf(".")));
var nb_items_file2 = parseInt(file2.args[1].slice(file2.args[1].indexOf("_")+1, file2.args[1].lastIndexOf(".")));
return nb_items_file1 - nb_items_file2;
});
run(to_run, "../results/add_csv_metadata.csv", function (err) {if (err) throw err;});
});
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var stream = fs.createWriteStream("../results/add_random_csv_attachment.csv", {flags:'a'});
fs.truncateSync("../results/add_random_csv_attachment.csv");
stream.write("items,ramUsed,memUsed\n");
var to_run = [{scriptPath : '../unit_tests/add_random_csv.js', args : ["-p", 1000000, "-s", "attachment"], amount : 1000000}];
run(to_run, "../results/add_random_csv_attachment.csv", function (err) {if (err) throw err;});
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var stream = fs.createWriteStream("../results/add_random_csv_metadata.csv", {flags:'a'});
fs.truncateSync("../results/add_random_csv_metadata.csv");
stream.write("items,ramUsed,memUsed\n");
var to_run = [{scriptPath : '../unit_tests/add_random_csv.js', args : ["-p", 1000000, "-s", "metadata"], amount : 1000000}];
run(to_run, "../results/add_random_csv_metadata.csv", function (err) {if (err) throw err;});
/*jslint es6 */
"use strict";
var run = require('./run_scripts_sync').run;
const fs = require('fs');
var run = require("./run_scripts_sync").run;
const fs = require("fs");
var gen_random_content = require("../unit_tests/random_gen").gen_random_content;
var args = JSON.parse(process.argv[2]);
var stream = fs.createWriteStream(args.result_file, {flags: 'w+'});