Skip to content

Commit 3092d8d

Browse files
Add a --total option to benchmark_to_spreadsheet.js
This adds an option to the script to take the total of the time taken by the benchmarks instead of the results for each individual functions
1 parent fe75b71 commit 3092d8d

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

scripts/benchmark/benchmark_to_spreadsheet.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ let program = require('commander');
33

44
program
55
.arguments('<jsonFile>')
6+
.option('-t, --total', 'Only print the total time')
67
.action(function (jsonFile) {
78
let lineReader = require('readline').createInterface({
89
input: require('fs').createReadStream(jsonFile)
910
});
10-
console.log("class file; function name; execution time (ms);"
11-
+ "success; goals covered; total number of goals");
11+
const printTotalTime = typeof program.total != 'undefined';
12+
let totalTime = 0.0;
13+
if (!printTotalTime)
14+
console.log("class file; function name; execution time (ms);"
15+
+ "success; goals covered; total number of goals");
1216
lineReader.on('line', function (data) {
1317
let json = JSON.parse(data.toString());
18+
totalTime += parseFloat(json.execTime);
19+
if (printTotalTime)
20+
return;
1421
console.log(
1522
json.classFile +";" +
1623
json['function'].replace(/;/g, "_") + "; " +
@@ -19,5 +26,10 @@ program
1926
((typeof json.goals != 'undefined')? json.goals.goalsCovered : "0") + ";" +
2027
((typeof json.goals != 'undefined')? json.goals.totalGoals : ""));
2128
});
29+
if (printTotalTime) {
30+
lineReader.on('close', function () {
31+
console.log(jsonFile + "; " + totalTime)
32+
});
33+
}
2234
})
2335
.parse(process.argv);

0 commit comments

Comments
 (0)