Skip to content

Commit ad910f3

Browse files
authored
fix: use deterministic benchmark contribution data (JhaSourav07#1720)
## Summary This PR makes the benchmark dataset deterministic by replacing random contribution generation with a predictable calculation. ### Changes Made * Added a deterministic contribution count generator * Removed `Math.random()` from benchmark dataset creation * Preserved variation in contribution values while ensuring reproducibility ### Problem The benchmark previously generated a different dataset on every execution, making performance comparisons less reliable. ### Result Benchmark runs now use a consistent dataset, improving reproducibility and regression tracking. Closes JhaSourav07#1678
2 parents fed3c34 + 11d4719 commit ad910f3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/benchmark-svg.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ const baseParams = {
1818
speed: sanitizeSpeed('8s'),
1919
};
2020

21+
const deterministicContributionCount = (weekIndex: number, dayIndex: number): number => {
22+
return ((weekIndex * 7 + dayIndex) * 13) % 20;
23+
};
24+
2125
const calendar = {
2226
totalContributions: 1240,
2327
weeks: Array.from({ length: 14 }, (_, weekIndex) => ({
2428
contributionDays: Array.from({ length: 7 }, (_, dayIndex) => ({
25-
contributionCount: Math.floor(Math.random() * 20),
29+
contributionCount: deterministicContributionCount(weekIndex, dayIndex),
2630
date: `2026-05-${String(weekIndex * 7 + dayIndex + 1).padStart(2, '0')}`,
2731
})),
2832
})),

0 commit comments

Comments
 (0)