Skip to content

Commit 5fdd406

Browse files
sup3xclaude
andcommitted
fix: address final review findings
- Guard against division-by-zero in summary when totalRequests is 0 - Fix runner grace period: break semaphore loop on abort so in-flight requests can be waited on with 3s timeout - Remove unused cli-table3 dependency Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent cc43b1f commit 5fdd406

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
"engines": { "node": ">=18" },
2121
"dependencies": {
2222
"chalk": "^5.3.0",
23-
"cli-table3": "^0.6.5",
2423
"commander": "^12.1.0",
2524
"undici": "^7.0.0"
2625
},

src/core/runner.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ export async function runBenchmark(
5757
// Semaphore: when one completes, start another
5858
while (inFlight.size > 0) {
5959
await Promise.race(inFlight);
60+
if (signal?.aborted) break;
6061
while (inFlight.size < effectiveConcurrency && shouldContinue()) {
6162
startRequest();
6263
}

src/output/summary.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ export function renderSummary(stats: BenchmarkStats, url: string): string {
1313
lines.push(DIVIDER);
1414
lines.push('');
1515
lines.push(` Total Requests ${formatNumber(stats.totalRequests)}`);
16-
lines.push(` Succeeded ${success(String(stats.succeeded))} ${dim(`(${formatPercent((stats.succeeded / stats.totalRequests) * 100)})`)}`);
16+
const successPct = stats.totalRequests > 0 ? (stats.succeeded / stats.totalRequests) * 100 : 0;
17+
lines.push(` Succeeded ${success(String(stats.succeeded))} ${dim(`(${formatPercent(successPct)})`)}`);
1718
if (stats.failed > 0) {
18-
lines.push(` Failed ${error(String(stats.failed))} ${dim(`(${formatPercent((stats.failed / stats.totalRequests) * 100)})`)}`);
19+
const failPct = stats.totalRequests > 0 ? (stats.failed / stats.totalRequests) * 100 : 0;
20+
lines.push(` Failed ${error(String(stats.failed))} ${dim(`(${formatPercent(failPct)})`)}`);
1921
}
2022
lines.push(` Total Time ${formatMs(stats.totalTimeMs)}`);
2123
lines.push(` Requests/sec ${bold(formatNumber(stats.requestsPerSec))}`);

0 commit comments

Comments
 (0)