Skip to content

Instantly share code, notes, and snippets.

@tsur
Created April 21, 2017 14:29
Show Gist options
  • Save tsur/2c0ab27a115fe85ca06b3450b1962dc4 to your computer and use it in GitHub Desktop.
Save tsur/2c0ab27a115fe85ca06b3450b1962dc4 to your computer and use it in GitHub Desktop.
Frames Per Second
<!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