Skip to content

Commit 4c3b009

Browse files
committed
fix(stress-tests): update stress test script to use npx and optimize performance scoring
1 parent 6c36d8f commit 4c3b009

File tree

2 files changed

+41
-47
lines changed

2 files changed

+41
-47
lines changed

.github/workflows/stress-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ jobs:
6161
cd ..
6262
6363
- name: Run stress tests (CI mode)
64-
run: tsx scripts/stress-test.ts --ci --output-file stress-test-results.json
64+
run: npx tsx scripts/stress-test.ts --ci --output-file stress-test-results.json
6565
timeout-minutes: 20
6666

6767
- name: Upload stress test results

scripts/stress-test.ts

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,49 @@ async function runStressTest(): Promise<void> {
293293
);
294294
console.log("");
295295

296+
// Calculate performance data (needed for both output modes)
297+
const scenarios = [...new Set(results.map((r) => r.scenario))];
298+
const drivers = [...new Set(results.map((r) => r.driver))];
299+
300+
const overallScores: Record<string, number> = {};
301+
for (const driver of drivers) {
302+
const driverResults = results.filter(
303+
(r) => r.driver === driver && !r.error,
304+
);
305+
if (driverResults.length === 0) continue;
306+
307+
let totalScore = 0;
308+
let scenarioCount = 0;
309+
310+
for (const scenarioKey of scenarios) {
311+
const result = driverResults.find((r) => r.scenario === scenarioKey);
312+
if (!result) continue;
313+
314+
// Find the fastest for this scenario
315+
const scenarioResults = results.filter(
316+
(r) => r.scenario === scenarioKey && !r.error,
317+
);
318+
const maxOps = Math.max(...scenarioResults.map((r) => r.avgOpsPerSec));
319+
320+
if (maxOps > 0) {
321+
totalScore += (result.avgOpsPerSec / maxOps) * 100;
322+
scenarioCount++;
323+
}
324+
}
325+
326+
if (scenarioCount > 0) {
327+
overallScores[driver] = Math.round(totalScore / scenarioCount);
328+
}
329+
}
330+
331+
const rankedDrivers = Object.entries(overallScores).sort(
332+
([, a], [, b]) => b - a,
333+
);
334+
296335
if (options.output === "json") {
297336
console.log(JSON.stringify(results, null, 2));
298337
} else {
299338
// Create performance comparison table
300-
const scenarios = [...new Set(results.map((r) => r.scenario))];
301-
const drivers = [...new Set(results.map((r) => r.driver))];
302-
303339
console.log("| Scenario | " + drivers.join(" | ") + " |");
304340
console.log(
305341
"|" + ["---"].concat(drivers.map(() => "---:")).join("|") + "|",
@@ -335,43 +371,6 @@ async function runStressTest(): Promise<void> {
335371
console.log(chalk.bold.cyan("\n🏆 Overall Performance Ranking"));
336372
console.log("");
337373

338-
const overallScores: Record<string, number> = {};
339-
for (const driver of drivers) {
340-
const driverResults = results.filter(
341-
(r) => r.driver === driver && !r.error,
342-
);
343-
if (driverResults.length === 0) continue;
344-
345-
let totalScore = 0;
346-
let scenarioCount = 0;
347-
348-
for (const scenarioKey of scenarios) {
349-
const result = driverResults.find((r) => r.scenario === scenarioKey);
350-
if (!result) continue;
351-
352-
// Find the fastest for this scenario
353-
const scenarioResults = results.filter(
354-
(r) => r.scenario === scenarioKey && !r.error,
355-
);
356-
const maxOps = Math.max(
357-
...scenarioResults.map((r) => r.avgOpsPerSec),
358-
);
359-
360-
if (maxOps > 0) {
361-
totalScore += (result.avgOpsPerSec / maxOps) * 100;
362-
scenarioCount++;
363-
}
364-
}
365-
366-
if (scenarioCount > 0) {
367-
overallScores[driver] = Math.round(totalScore / scenarioCount);
368-
}
369-
}
370-
371-
const rankedDrivers = Object.entries(overallScores).sort(
372-
([, a], [, b]) => b - a,
373-
);
374-
375374
console.log("| Rank | Driver | Score |");
376375
console.log("|---:|---|---:|");
377376

@@ -421,12 +420,7 @@ async function runStressTest(): Promise<void> {
421420
totalTests: results.length,
422421
successfulTests: results.filter((r) => !r.error).length,
423422
failedTests: results.filter((r) => r.error).length,
424-
overallScores: Object.fromEntries(
425-
Object.entries(overallScores ?? {}).map(([driver, score]) => [
426-
driver,
427-
score,
428-
]),
429-
),
423+
overallScores,
430424
},
431425
};
432426

0 commit comments

Comments
 (0)