Skip to content

Commit aed7c65

Browse files
authored
polish(benchmark): handle theoretical stats errors (#4687)
1 parent f51686a commit aed7c65

2 files changed

Lines changed: 14 additions & 7 deletions

File tree

resources/benchmark/run.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,23 @@ function runBenchmark(
6262

6363
const results: Array<BenchmarkResult> = [];
6464
for (let i = 0; i < benchmarkProjects.length; ++i) {
65-
results.push(
66-
computeStats(
65+
let result: BenchmarkResult;
66+
try {
67+
result = computeStats(
6768
benchmarkProjects[i].revision,
6869
timingSamples[i],
6970
memorySamples[i],
70-
),
71-
);
71+
);
72+
} catch (error) {
73+
const errorMessage =
74+
error instanceof Error ? error.message : String(error);
75+
console.log(
76+
' ' + benchmarkProjects[i].revision + ': ' + red(errorMessage),
77+
);
78+
return;
79+
}
80+
81+
results.push(result);
7282
}
7383

7484
console.log('\n');

resources/benchmark/statistics.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export function computeStats(
2121
timingSamples: ReadonlyArray<number>,
2222
memorySamples: ReadonlyArray<number>,
2323
): BenchmarkResult {
24-
assert(timingSamples.length > 1);
25-
assert(memorySamples.length > 0);
26-
2724
const { mean, marginOfError } = computeMeanStats(timingSamples);
2825

2926
let meanMemUsed = 0;

0 commit comments

Comments
 (0)