Skip to content

Instantly share code, notes, and snippets.

@cvazac
Created May 10, 2017 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cvazac/6b1f11fc029239198a54d686bc77dbde to your computer and use it in GitHub Desktop.
Save cvazac/6b1f11fc029239198a54d686bc77dbde to your computer and use it in GitHub Desktop.
(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