Balázs,
Thanks for your description of the event queue. Is there a way to get
the event queue? Via Firebug or another browser's developer tools?

Thanks again.

On Jan 14, 11:37 am, Balázs Galambosi <galambal...@gmail.com> wrote:
> 2011/1/14 foldi <foldifoldi.vi...@gmail.com>:
>
> > I'm trying to understand something about setInterval. When running the
> > following in FF3, the time it takes to execute the interval's function
> > does not take longer than the 30ms specified for the interval.
> > However, it takes longer than 30ms to for the interval to run again.
> > Where is the extra time going? Is there always some overhead to
> > running a setInterval? Thanks [code]
>
> In browsers Javascript is executed in an event loop. Consider a click event,
> or a setTimeout/setInterval. These cases don't execute the code immediately,
> they push it to the so-called event queue instead.
>
> So when you click a button, what happens is that your click event enters
> this queue and when nothing else is left the onclick handlers are
> executed (in order).
> Because of this, anything that gets to the queue before the click event has 
> the
> possibility to block. If the thread (the one and only) is blocked then
> the upcoming actions
> are delayed. In a case of a click event you experience a bit of
> sluggishness in the UI.
>
> So much is the case with setInterval. It tries to execute the given
> function in time,
> but if there's anything in the queue that may delay the execution of
> your function.
>
> I think setInterval itself is highly optimized, and as such shouldn't
> cause any significant
> overhead by itself.
>
> - Balázs

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/jsmentors@jsmentors.com/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/jsmentors@googlegroups.com/

To unsubscribe from this group, send email to
jsmentors+unsubscr...@googlegroups.com

Reply via email to