Hacker News new | ask | show | jobs
by ck2 5569 days ago
Just adding some documentation about the limits of setTimeout and setInterval - Chrome has now settled on 4ms minimum (HTML5 standard) and Firefox 3 throttles lower values back up to 10ms minimum:

https://developer.mozilla.org/en/window.setTimeout#Minimum_d...

http://code.google.com/p/chromium/issues/detail?id=888#c4

We observed that current browsers already do not have a stable and consistent clock. As it turns out, even FF3 uses varying timer speeds of either 15.6ms or 10ms. The reason for this variance is because FF3 uses the default windows timer mechanisms by default; which have a 15.6ms clock granularity. However, these timers are influenced by the system-wide timeGetTime() API. Flash, Quicktime, and Windows Media all set timeBeginPeriod(1), which changes the clock resolution to 1ms. In this case, FF then applies a clamp to avoid sub-10ms timers. This can be tested by starting with a blank system w/ only FF running, and using this tool: http://ejohn.org/apps/timers/ Then load youtube (flash causes the beginTimePeriod to be called) in a background tab and run your test again. You'll see the clock speed drop from 15ms to 10ms. So, as you can see, a web developer today could be running IE w/ a 15ms minimum, FF, with a varying 10/15ms minimum, or another browser with who-knows-what for a minimum timeout.