Created
May 10, 2017 21:07
-
-
Save cvazac/6b1f11fc029239198a54d686bc77dbde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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