From ea3d9df238727d03c950e53a9184bda7b80bfee0 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 6 Oct 2025 16:52:20 +0000 Subject: [PATCH 1/2] Add performance metrics tracking to Autobahn test parser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enhance parse-results.js to capture and display timing data: - Track total test duration and per-test averages - Categorize performance-focused tests (9.x limits, 10.x large messages, 12.x fragmentation) - Display category breakdowns with average durations - Show top 5 slowest tests per performance category Performance summary now shows: - 9.x (Limits/Performance): 54 tests, avg 175.56ms - 10.x (Large Messages): 1 test, avg 7.00ms - 12.x (Fragmentation): 90 tests, avg 1.23ms 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- test/autobahn/parse-results.js | 84 ++++++++++++++++++++++++++++++++-- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/test/autobahn/parse-results.js b/test/autobahn/parse-results.js index ce0628d9..88049902 100755 --- a/test/autobahn/parse-results.js +++ b/test/autobahn/parse-results.js @@ -34,16 +34,26 @@ function parseResults() { failedTests: [], nonStrictTests: [], unimplementedTests: [], - informationalTests: [] + informationalTests: [], + performance: { + totalDuration: 0, + testCount: 0, + byCategory: { + 'limits': { tests: [], totalDuration: 0, description: '9.x - Limits/Performance' }, + 'largeMessages': { tests: [], totalDuration: 0, description: '10.x - Large Messages' }, + 'fragmentation': { tests: [], totalDuration: 0, description: '12.x - WebSocket Fragmentation' }, + 'other': { tests: [], totalDuration: 0, description: 'Other Tests' } + } + } }; // Parse each test case for (const [testCase, result] of Object.entries(testResults)) { summary.total++; - + const behavior = result.behavior; const behaviorClose = result.behaviorClose; - + if (behavior === 'OK' && behaviorClose === 'OK') { summary.ok++; } else if (behavior === 'UNIMPLEMENTED') { @@ -81,6 +91,31 @@ function parseResults() { remoteCloseCode: result.remoteCloseCode }); } + + // Track performance metrics + if (result.duration !== undefined) { + summary.performance.totalDuration += result.duration; + summary.performance.testCount++; + + // Categorize performance tests + const majorCategory = testCase.split('.')[0]; + let category = 'other'; + + if (majorCategory === '9') { + category = 'limits'; + } else if (majorCategory === '10') { + category = 'largeMessages'; + } else if (majorCategory === '12') { + category = 'fragmentation'; + } + + summary.performance.byCategory[category].tests.push({ + case: testCase, + duration: result.duration, + description: result.description + }); + summary.performance.byCategory[category].totalDuration += result.duration; + } } // Print summary @@ -144,7 +179,48 @@ function parseResults() { } } - console.log('\n'); + // Print performance summary + if (summary.performance.testCount > 0) { + console.log('=== PERFORMANCE METRICS ==='); + console.log(` Total test duration: ${summary.performance.totalDuration.toLocaleString()}ms`); + console.log(` Tests with timing data: ${summary.performance.testCount}`); + console.log(` Average duration: ${(summary.performance.totalDuration / summary.performance.testCount).toFixed(2)}ms\n`); + + // Print category breakdown for performance-focused tests + const perfCategories = ['limits', 'largeMessages', 'fragmentation']; + let hasPerfData = false; + + for (const categoryKey of perfCategories) { + const category = summary.performance.byCategory[categoryKey]; + if (category.tests.length > 0) { + hasPerfData = true; + const avgDuration = (category.totalDuration / category.tests.length).toFixed(2); + console.log(` ${category.description}:`); + console.log(` Tests: ${category.tests.length}`); + console.log(` Total duration: ${category.totalDuration.toLocaleString()}ms`); + console.log(` Average duration: ${avgDuration}ms`); + + // Show top 5 slowest tests in this category + const slowestTests = category.tests + .sort((a, b) => b.duration - a.duration) + .slice(0, 5); + + if (slowestTests.length > 0) { + console.log(' Slowest tests:'); + slowestTests.forEach(test => { + console.log(` ${test.case}: ${test.duration}ms`); + }); + } + console.log(''); + } + } + + if (!hasPerfData) { + console.log(' No performance-focused tests (9.x, 10.x, 12.x) executed.\n'); + } + } + + console.log(''); // Exit with error code if there are actual failures if (summary.failed > 0) { From 63b464546e81094b9accdf36a97b3717e373043f Mon Sep 17 00:00:00 2001 From: Claude Code Date: Mon, 6 Oct 2025 16:56:46 +0000 Subject: [PATCH 2/2] Address Gemini code review feedback MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix high priority issues: - Prevent array mutation by copying before sorting (line 204) Fix medium priority issues: - Use map object for cleaner category mapping (lines 51-55, 109) - Rename 'case' property to 'testCase' to avoid reserved keyword (lines 112, 210) - Dynamically generate performance categories from object keys (line 189) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- test/autobahn/parse-results.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/test/autobahn/parse-results.js b/test/autobahn/parse-results.js index 88049902..6aad48d0 100755 --- a/test/autobahn/parse-results.js +++ b/test/autobahn/parse-results.js @@ -47,6 +47,13 @@ function parseResults() { } }; + // Category mapping for performance tests + const categoryMap = { + '9': 'limits', + '10': 'largeMessages', + '12': 'fragmentation' + }; + // Parse each test case for (const [testCase, result] of Object.entries(testResults)) { summary.total++; @@ -99,18 +106,10 @@ function parseResults() { // Categorize performance tests const majorCategory = testCase.split('.')[0]; - let category = 'other'; - - if (majorCategory === '9') { - category = 'limits'; - } else if (majorCategory === '10') { - category = 'largeMessages'; - } else if (majorCategory === '12') { - category = 'fragmentation'; - } + const category = categoryMap[majorCategory] || 'other'; summary.performance.byCategory[category].tests.push({ - case: testCase, + testCase: testCase, duration: result.duration, description: result.description }); @@ -187,7 +186,7 @@ function parseResults() { console.log(` Average duration: ${(summary.performance.totalDuration / summary.performance.testCount).toFixed(2)}ms\n`); // Print category breakdown for performance-focused tests - const perfCategories = ['limits', 'largeMessages', 'fragmentation']; + const perfCategories = Object.keys(summary.performance.byCategory).filter(key => key !== 'other'); let hasPerfData = false; for (const categoryKey of perfCategories) { @@ -201,14 +200,14 @@ function parseResults() { console.log(` Average duration: ${avgDuration}ms`); // Show top 5 slowest tests in this category - const slowestTests = category.tests + const slowestTests = [...category.tests] .sort((a, b) => b.duration - a.duration) .slice(0, 5); if (slowestTests.length > 0) { console.log(' Slowest tests:'); slowestTests.forEach(test => { - console.log(` ${test.case}: ${test.duration}ms`); + console.log(` ${test.testCase}: ${test.duration}ms`); }); } console.log('');