Skip to content

Commit

Permalink
Print normal ratios by default (confidence with flag)
Browse files Browse the repository at this point in the history
  • Loading branch information
dubzzz committed Nov 3, 2020
1 parent d16d8ac commit 51c087a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions perf/benchmark.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ const argv = yargs(hideBin(process.argv))
default: false,
description: 'Do not check for local changes, your local changes will be automatically stashed and un-stashed',
})
.option('print-confidence', {
type: 'boolean',
default: false,
description: 'Print confidence range in reports',
})
.option('verbose', {
alias: 'v',
type: 'boolean',
Expand Down Expand Up @@ -323,7 +328,10 @@ async function run() {
const table = new Table({
columns: [
{ name: 'Name', alignment: 'left' },
...configurations.map(([configName]) => ({ name: configName, alignment: 'center' })),
...configurations.map(([configName]) => ({
name: configName,
alignment: argv['print-confidence'] ? 'center' : 'right',
})),
],
});
// Find the best and worst configurations
Expand All @@ -341,6 +349,7 @@ async function run() {
const currentBenchStats = benchmarkStatsFor(currentConfigIndex, testIndex);
// [mean - 2 * sigma, mean + 2 * sigma] is 95 %
const currentBenchWorst = Math.max(Number.MIN_VALUE, currentBenchStats.mean - 2 * currentBenchStats.deviation);
const currentBenchMean = currentBenchStats.mean;
const currentBenchBest = currentBenchStats.mean + 2 * currentBenchStats.deviation;
table.addRow(
{
Expand All @@ -352,10 +361,16 @@ async function run() {
}
const otherBenchStats = benchmarkStatsFor(configIndex, testIndex);
const otherBenchWorst = Math.max(Number.MIN_VALUE, otherBenchStats.mean - 2 * otherBenchStats.deviation);
const otherBenchMean = otherBenchStats.mean;
const otherBenchBest = otherBenchStats.mean + 2 * otherBenchStats.deviation;
const ratioWorst = (100.0 * otherBenchWorst) / currentBenchBest - 100.0;
const ratio = (100.0 * otherBenchMean) / currentBenchMean - 100.0;
const ratioBest = (100.0 * otherBenchBest) / currentBenchWorst - 100.0;
return [config[0], `${formatRatio(ratioWorst)}${formatRatio(ratioBest)}`]; // ~95% interval
if (argv['print-confidence']) {
return [config[0], `${formatRatio(ratioWorst)}${formatRatio(ratioBest)}`]; // ~95% interval
} else {
return [config[0], formatRatio(ratio)];
}
})
),
},
Expand Down

0 comments on commit 51c087a

Please sign in to comment.