Clean up perf run dirs and cover collector reset
- Persist and remove the seeded run parent directory after perf runs - Add regression coverage for seed cleanup, percentile clamping, and RAF reset
This commit is contained in:
1 parent
b8fba18575
commit
062c809aa0
10 files changed
+256
-432
No files matched your search
@@ -68,7 +68,10 @@ export function percentile(values: ReadonlyArray<number>, target: number): numbe
|
||||
}
|
||||
const sorted = values.toSorted((left, right) => left - right);
|
||||
const clampedTarget = Math.min(Math.max(target, 0), 1);
|
||||
const index = Math.min(sorted.length - 1, Math.ceil(sorted.length * clampedTarget) - 1);
|
||||
const index = Math.min(
|
||||
sorted.length - 1,
|
||||
Math.max(0, Math.ceil(sorted.length * clampedTarget) - 1),
|
||||
);
|
||||
return sorted[index] ?? null;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,15 +30,16 @@ export function installBrowserPerfCollector(
|
||||
const rafGapsMs: number[] = [];
|
||||
const mountedRowSamples: Array<BrowserPerfMetrics["mountedRowSamples"][number]> = [];
|
||||
let previousAnimationFrameTs = 0;
|
||||
let rafHandle = 0;
|
||||
|
||||
const animationFrameLoop = (timestampMs: number) => {
|
||||
if (previousAnimationFrameTs > 0) {
|
||||
rafGapsMs.push(timestampMs - previousAnimationFrameTs);
|
||||
}
|
||||
previousAnimationFrameTs = timestampMs;
|
||||
window.requestAnimationFrame(animationFrameLoop);
|
||||
rafHandle = window.requestAnimationFrame(animationFrameLoop);
|
||||
};
|
||||
window.requestAnimationFrame(animationFrameLoop);
|
||||
rafHandle = window.requestAnimationFrame(animationFrameLoop);
|
||||
|
||||
if (typeof PerformanceObserver !== "undefined") {
|
||||
try {
|
||||
@@ -103,7 +104,8 @@ export function installBrowserPerfCollector(
|
||||
rafGapsMs.length = 0;
|
||||
mountedRowSamples.length = 0;
|
||||
previousAnimationFrameTs = 0;
|
||||
window.requestAnimationFrame(animationFrameLoop);
|
||||
window.cancelAnimationFrame(rafHandle);
|
||||
rafHandle = window.requestAnimationFrame(animationFrameLoop);
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user