On Sat, Feb 12, 2011 at 11:58 AM, Julian Turner <[email protected]> wrote:
> setTimeout : GO-BUT SLOW AND COMPLEX
>
> The next solution was to use a "continuation" style of programming,
> with setTimeout; which seemed to be the most common solution on a
> search.
>
> This involves carrying out each iteration of the function in a
> timeout, and then calling setTimeout again, with the current state.
> The display then updates between timeouts.
>
> I found this complex to implement, and too slow for my requirements.

Regarding setTimeout, of course "carrying out each iteration" will be
slow, because there's function call overhead and a minimum time limit
between timeouts (usually ~15ms).  The way to enhance this technique
is to only set up a new timeout after a good amount of operations (or
if a certain amount of time has passed).

You can also give David Baron's setZeroTimeout a try. It removes the
~15ms delay between timeouts, making your code much faster overall.
http://dbaron.org/log/20100309-faster-timeouts

- Balázs

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to