Skip to content

Commit

Permalink
OK but what if I made a data visualization for very good reasons
Browse files Browse the repository at this point in the history
  • Loading branch information
philrenaud committed Dec 5, 2024
1 parent aed33ae commit b8f9c28
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test-ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ jobs:
body += `- Current: ${comp.currentDuration}ms\n`;
body += `- Historical Avg: ${comp.historicalAverage}ms\n`;
body += `- Change: ${comp.percentDiff?.toFixed(1) || 'N/A'}%\n\n`;
body += `- Trend: ${comp.trend}\n\n`;
});
}
Expand Down
23 changes: 22 additions & 1 deletion scripts/analyze-ui-test-times.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ testStats.forEach(([testName, count]) => {
currentDuration,
historicalAverage,
percentDiff, // This will now always be a number
samples: count
samples: count,
historicalTimings: testTimings.get(testName) || [],
trend: createSparkline(testTimings.get(testName) || [], currentDuration)
});

if (percentDiff > 0) {
Expand Down Expand Up @@ -221,6 +223,25 @@ testStats.forEach(([testName, count]) => {
}
}

function createSparkline(timings, currentValue) {
const blocks = ['▁', '▂', '▃', '▄', '▅', '▆', '▇', '█'];
const min = Math.min(...timings);
const max = Math.max(...timings);
const range = max - min;

const sparkline = timings.map(value => {
const normalized = range === 0 ? 0 : (value - min) / range;
const blockIndex = Math.floor(normalized * (blocks.length - 1));
return blocks[blockIndex];
}).join('');

const avgHistorical = timings.reduce((a, b) => a + b, 0) / timings.length;
const trend = currentValue > avgHistorical ? '↑' : currentValue < avgHistorical ? '↓' : '→';
const trendColor = currentValue > avgHistorical ? '🔴' : currentValue < avgHistorical ? '🟢' : '⚪';

return `${sparkline} ${trend} ${trendColor}`;
}

if (require.main === module) {
analyzeTestTimes();
}
Expand Down

0 comments on commit b8f9c28

Please sign in to comment.