Calculate FPS in Canvas using requestAnimationFrame

Do not use new Date() This API has several flaws and is only useful for getting the current date + time. Not for measuring timespans. The Date-API uses the operating system’s internal clock, which is constantly updated and synchronized with NTP time servers. This means, that the speed / frequency of this clock is sometimes … Read more

Exact time of display: requestAnimationFrame usage and timeline

What you are experiencing is a Chrome bug (and even two). Basically, when the pool of requestAnimationFrame callbacks is empty, they’ll call it directly at the end of the current event loop, without waiting for the actual painting frame as the specs require. To workaround this bug, you can keep an ever-going requestAnimationFrame loop, but … Read more

Controlling fps with requestAnimationFrame?

How to throttle requestAnimationFrame to a specific frame rate Demo throttling at 5 FPS: http://jsfiddle.net/m1erickson/CtsY3/ This method works by testing the elapsed time since executing the last frame loop. Your drawing code executes only when your specified FPS interval has elapsed. The first part of the code sets some variables used to calculate elapsed time. … Read more