Advertisement
Almeidaa03

FPS

Dec 7th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let before = Date.now(), fps = 0, now;
  2. requestAnimationFrame(loop);
  3.  
  4. function loop() {
  5.   now = Date.now();
  6.   fps = Math.round(1000 / (now - before));
  7.   before = now;
  8.   requestAnimationFrame(loop);
  9.   console.log('FPS:', fps);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement