Script to convert json benchmarks to csv

Add a script which takes the output of the benchmark_java_project.js
script (in json) and format it as a csv file.
This commit is contained in:
Romain Brenguier 2018-12-07 09:06:24 +00:00
parent 9d112e5980
commit 19c07d61e7
1 changed files with 23 additions and 0 deletions

View File

@ -0,0 +1,23 @@
#!/usr/bin/env node
let program = require('commander');
program
.arguments('<jsonFile>')
.action(function (jsonFile) {
let lineReader = require('readline').createInterface({
input: require('fs').createReadStream(jsonFile)
});
console.log("class file; function name; execution time (ms);"
+ "success; goals covered; total number of goals");
lineReader.on('line', function (data) {
let json = JSON.parse(data.toString());
console.log(
json.classFile +";" +
json['function'].replace(/;/g, "_") + "; " +
json.execTime + ";" +
json.success + ";" +
((typeof json.goals != 'undefined')? json.goals.goalsCovered : "0") + ";" +
((typeof json.goals != 'undefined')? json.goals.totalGoals : ""));
});
})
.parse(process.argv);