Skip to content

Commit 28675a1

Browse files
committed
Sort benchmarks by name
1 parent 41d4278 commit 28675a1

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

benchmark/src/run.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,20 @@ function benchmark(): void {
4141
}
4242
benchmark();
4343

44+
function sortByName({ benchmarkName: a }: BenchmarkResult, { benchmarkName: b }: BenchmarkResult): number {
45+
if (a < b) return -1;
46+
if (a > b) return 1;
47+
return 0;
48+
}
49+
4450
function compareBenchmarks(oldResults: BenchmarkResult[], newResults: BenchmarkResult[]): ComparisonInfo {
45-
const oldResultsMemory = oldResults.filter(isMemoryBenchmarkResult);
46-
const newResultsMemory = newResults.filter(isMemoryBenchmarkResult);
51+
const oldResultsMemory = oldResults.filter(isMemoryBenchmarkResult).sort(sortByName);
52+
const newResultsMemory = newResults.filter(isMemoryBenchmarkResult).sort(sortByName);
4753

4854
const memoryComparisonInfo = compareMemoryBenchmarks(oldResultsMemory, newResultsMemory);
4955

50-
const oldResultsRuntime = oldResults.filter(isRuntimeBenchmarkResult);
51-
const newResultsRuntime = newResults.filter(isRuntimeBenchmarkResult);
56+
const oldResultsRuntime = oldResults.filter(isRuntimeBenchmarkResult).sort(sortByName);
57+
const newResultsRuntime = newResults.filter(isRuntimeBenchmarkResult).sort(sortByName);
5258

5359
const runtimeComparisonInfo = compareRuntimeBenchmarks(oldResultsRuntime, newResultsRuntime);
5460

0 commit comments

Comments
 (0)