Skip to content

Commit 5c47d38

Browse files
authored
chore: Sort treeshake-test results by impact in GitHub comments (#2268)
1 parent 7e812aa commit 5c47d38

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

apps/treeshake-test/resultsTable.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ export class ResultsTable {
5050
}
5151
output += ' |\n';
5252

53-
for (const [test, row] of this.#results.entries()) {
53+
const sortedResults = [...this.#results.entries()]
54+
.map(([test, row]) => [test, row, this.#maxAbsoluteChange(row)] as const)
55+
.toSorted(([, , scoreA], [, , scoreB]) => scoreB - scoreA)
56+
.map(([test, row]) => [test, row] as const);
57+
58+
for (const [test, row] of sortedResults) {
5459
output += `| ${test.replaceAll('_', ' ')}`;
5560

5661
for (const bundler of this.#bundlers) {
@@ -78,6 +83,16 @@ ${output}
7883
return output;
7984
}
8085

86+
#maxAbsoluteChange(row: Row): number {
87+
let max = 0;
88+
for (const { pr, target } of row.values()) {
89+
if (pr !== undefined && target !== undefined && target !== 0) {
90+
max = Math.max(max, Math.abs((pr - target) / target));
91+
}
92+
}
93+
return max;
94+
}
95+
8196
#isInteresting(row: Row) {
8297
for (const cell of row) {
8398
const pr = cell[1].pr;

0 commit comments

Comments
 (0)