Skip to content

Instantly share code, notes, and snippets.

@cvazac
Created May 10, 2017
Embed
What would you like to do?
(function() {
if (window !== top) return;
const bucketSize = 500, threshold = 30, stamps = []
function measureFps() {
const now = performance.now()
if (stamps.length) {
while (now - stamps[0] > bucketSize) {
stamps.shift()
}
const fps = stamps.length * 1000 / bucketSize
if (fps >= threshold) {
console.warn(`fps was ${fps} from ${stamps[0]} to ${now} -- tti=${stamps[0]}`);
return;
}
}
stamps.push(now)
window.requestAnimationFrame(measureFps);
}
window.requestAnimationFrame(measureFps);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment