On 18/12/06, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> Ok, so I put together a little test page at
> http://test.learningjquery.com/speed-test.htm
>
> I run the following queries, using .click() and checking the difference
> between the time they start and the time they end (on FF2 Mac):
> $(.dialog)
> $(div.dialog)
> $(div).filter('.dialog')
>
> There are 49 DIVs with class="dialog" on the page.
>
> $(.dialog) averages ~30 milliseconds
> $(div.dialog) and $(div).filter('.dialog') usually clock in
> around 19-20 milliseconds
>
> The first one to be clicked typically takes about 10ms longer than
> subsequent clicks on it.
>
> Here is the really weird part:
> On every 7th click, the query will take 70 - 85 milliseconds, no matter
> which one is clicked or what the order is.
>
> I figure there must be something really stupid about the way I'm doing this.
>  All the code is in the <head>, so feel free to take a look, and if it's
> really dumb, post to the list and let everyone know to disregard these
> numbers. If it's not so dumb and someone wants to test it on another
> system/browser, I'd be interested to hear what your results are.
>
>
> --Karl
> _________________
> Karl Swedberg
> www.englishrules.com
> www.learningjquery.com

The seven click bug does not exist in IE7. The speeds are about the
same (about 10ms slower than you) in both Firefox and IE. If you
change tabs on the sixth click and then go back, there is not the big
jump.

$('.dialog') - alternates between 47 and 62 and up to 156/172/187
$('div.dialog') - 31/32 and 15/16 up to 141/156
$('div').filter('.dialog') - same as div.dialog

It does show that selecting using a tag is marginally faster, but not
fast enough to really notice (but you may notice on a really
complicated page (which won't exist if you use good markup and try to
limit the number of tables)).

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to