Last active
November 17, 2022 17:44
-
-
Save almeidx/f175de7582ac83e9b8051b95e018f321 to your computer and use it in GitHub Desktop.
Show the FPS of a window
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
let before = Date.now(), fps = 0, now; | |
requestAnimationFrame(function loop() { | |
now = Date.now(); | |
fps = Math.round(1000 / (now - before)); | |
before = now; | |
requestAnimationFrame(loop); | |
console.log('FPS:', fps); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment