Skip to content

Commit

Permalink
compare-multiple: use median
Browse files Browse the repository at this point in the history
  • Loading branch information
alxndrsn committed Apr 3, 2024
1 parent ae37cd2 commit 817a82e
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions bin/perf-test-results/compare-multiple.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,32 @@ rawResults.forEach(({ adapter, client, results }) => {
if (!testSuites[suite].includes(t)) testSuites[suite].push(t);

if (!resultsByAdapter[adapter][suite]) resultsByAdapter[adapter][suite] = {};
if (!resultsByAdapter[adapter][suite][t]) resultsByAdapter[adapter][suite][t] = { numIterations:0, min:Number.MAX_VALUE };
if (!resultsByAdapter[adapter][suite][t]) resultsByAdapter[adapter][suite][t] = { numIterations:0, min:Number.MAX_VALUE, median:-1, all:[] };

resultsByAdapter[adapter][suite][t].all.push(median);
resultsByAdapter[adapter][suite][t].min = Math.min(resultsByAdapter[adapter][suite][t].min, median);
resultsByAdapter[adapter][suite][t].numIterations++;
});
});

Object.values(resultsByAdapter).forEach(adapterRes => {
Object.values(adapterRes).forEach(suite => {
console.log('suite:', JSON.stringify(suite, null, 2));
Object.values(suite).forEach(test => {
console.log('test:', JSON.stringify(test, null, 2));
test.all.sort();
const len = test.all.length;
const mid = Math.floor(len / 2);
console.log({ len, mid });
if(len % 2) {

Check failure on line 58 in bin/perf-test-results/compare-multiple.js

View workflow job for this annotation

GitHub Actions / lint

Expected space(s) after "if"
test.median = test.all[mid];
} else {
test.median = (test.all[mid] + test.all[mid-1]) / 2;
}
});
});
});

if (adapters.length < 2) {
console.log('!!! At least 2 different adapters are required to make comparisons!');
process.exit(1);
Expand All @@ -56,4 +75,4 @@ const sortedResults = adapters.map(adapter => ({
adapter, results:resultsByAdapter[adapter]
}));

printComparisonReport({ useStat:'min' }, ...sortedResults);
printComparisonReport({ useStat:'median' }, ...sortedResults);

0 comments on commit 817a82e

Please sign in to comment.