chore: Update change detection logic

This commit is contained in:
Sidharth Vinod
2025-04-09 13:20:19 +05:30
parent 2396f90269
commit f87d0dd88a

View File

@@ -91,20 +91,22 @@ function compareTimings(): void {
if (!oldTiming) { if (!oldTiming) {
throw new Error(`Could not find old timing for spec: ${newTiming.spec}`); throw new Error(`Could not find old timing for spec: ${newTiming.spec}`);
} }
const change = Math.abs(newTiming.duration - oldTiming.duration) / oldTiming.duration; const change = Math.abs(newTiming.duration - oldTiming.duration);
return { spec: newTiming.spec, change }; const changePercent = change / oldTiming.duration;
return { spec: newTiming.spec, change, changePercent };
}); });
const significantChanges = timingChanges.filter((t) => t.change >= 0.2); // Filter changes that's more than 5 seconds and 20% different
const significantChanges = timingChanges.filter((t) => t.change > 5000 && t.changePercent >= 0.2);
if (significantChanges.length === 0) { if (significantChanges.length === 0) {
log('No significant timing changes detected (threshold: 20%)'); log('No significant timing changes detected (threshold: 5s and 20%)');
return cleanupFiles({ keepNew: false, reason: 'No significant timing changes' }); return cleanupFiles({ keepNew: false, reason: 'No significant timing changes' });
} }
log('Significant timing changes:'); log('Significant timing changes:');
significantChanges.forEach((t) => { significantChanges.forEach((t) => {
log(`${t.spec}: ${(t.change * 100).toFixed(1)}%`); log(`${t.spec}: ${t.change.toFixed(1)}ms (${(t.changePercent * 100).toFixed(1)}%)`);
}); });
cleanupFiles({ keepNew: true, reason: 'Significant timing changes detected' }); cleanupFiles({ keepNew: true, reason: 'Significant timing changes detected' });