Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions tools/perf/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,22 @@ function runBenchmark(benchmarkName, sample, results) {
}

function printResults(res) {
for (var scenario in res) {
for (const scenario in res) {
if (program.compare) {
var ref = JSON.parse(fs.readFileSync(program.compare).toString());
var delta = +(res[scenario].mean - ref[scenario].mean).toFixed(2);
var sig = !util.meansEqual(ref[scenario], res[scenario], 1 - program.alpha);
var relative = +(delta / ref[scenario].mean).toFixed(2)
const ref = JSON.parse(fs.readFileSync(program.compare).toString());
const delta = +(res[scenario].mean - ref[scenario].mean).toFixed(2);
const sig = !util.meansEqual(ref[scenario], res[scenario], 1 - program.alpha);
const relative = +(delta / ref[scenario].mean).toFixed(2)
if (program.raw) {
res[scenario].significant = sig;
res[scenario].delta = delta;
res[scenario].relative = relative;
} else {
var percent = (delta > 0 ? '+' : '') + relative * 100 + '%';
const percent = (delta > 0 ? '+' : '') + relative * 100 + '%';
if (!sig) {
res[scenario].mean += ' (' + percent + ')';
} else if (delta > 0) {
res[scenario].mean += color(' (' + percent + ')', BAD);
} else {
res[scenario].mean += color(' (' + percent + ')', GOOD);
res[scenario].mean += color(' (' + percent + ')', (delta > 0) ? BAD : GOOD );
}
}
}
Expand All @@ -135,8 +133,8 @@ function printResults(res) {
console.log(JSON.stringify(res, null, 2));
} else {
console.log(prettyjson.render(res, {
keysColor: 'cyan',
dashColor: 'cyan',
keysColor: INDICATOR,
dashColor: INDICATOR,
}));
}
}