Created
April 21, 2017 14:29
-
-
Save tsur/2c0ab27a115fe85ca06b3450b1962dc4 to your computer and use it in GitHub Desktop.
Frames Per Second
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
// 16ms - 60 fps, f = 1000/t | |
let lastDelta = Date.now(); | |
function loop(){ | |
const now = Date.now(); | |
console.log('FPS', 1000/(now - lastDelta)); | |
lastDelta = now; | |
requestAnimationFrame(loop); | |
} | |
requestAnimationFrame(loop); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment