3 ms·
I believe this test proves little useful across different browsers on different OS/hardware because setInterval and setTimeout cannot fire faster than 8-10ms on
by ck2 16y ago
I believe this test proves little useful across different browsers on different OS/hardware because setInterval and setTimeout cannot fire faster than 8-10ms on most browsers and every browser handles a "1ms" request differently.
http://dbaron.org/log/20100309-faster-timeouts http://dbaron.org/log/20100309-faster-timeouts
However the postMessage trick is near realtime:
http://dbaron.org/mozilla/zero-timeout http://dbaron.org/mozilla/zero-timeout
- seanalltogether 16y agoThe point of a settimeout or setinterval is that it will always process in the next run loop. I don't see how postMessage actually provides anything over calling a function directly.
- ck2 16y agoWhen I update to setZeroTimeout in those canvas vs svg demos, the drawing is so fast there is horizontal tearing and the frame rates are in the thousands. Which means the FPS with setInterval is actually measuring how long it takes setInterval to fire, not how long it's taking to draw under the different methods.
- hertog 16y agoVery interesting. Do you think it will make a difference on mobile devices?
- seanalltogether 16y agoBut that's a feature you don't really want. You're blowing away your cpu on something that can only display 60 times a second.
- ck2 16y agoThe code in question is a benchmark of how fast two different render APIs work. The only way to do that reliably is to take the question of the timer firing rate out of the equation. I doubt you'd use setZeroTimeout in most realworld environments.