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
On Dec 17, 2006, at 8:48 PM, Stephen Woodbridge wrote:
I seem to remember seeing that post also and having done a lot of
testing in other jobs it is easy to make tests the are not
representative, misleading, or distort reality, etc. However this
is not
an excuse for not developing tests, it should be just a caution
that you
need to be aware of what you are measuring.
Having some standard tests that compare different searches using some
standard, that ever that might be, complexity pages, may not reflect
real-life queries, but it would give us some standards to compare
against from version to version and if we find cases that are not well
represented then we can add more cases.
My $.02,
-Steve
Karl Swedberg wrote:
I'd like to see some real benchmarks on this, too. Is it possible
to rig
up the test suite to do something like that?
On the other hand, won't the speeds (and the respective difference in
speeds) depend to some extent on the complexity of the page?
I seem to recall having read a pretty convincing argument by
someone on
this list (Michael Geary maybe?) about the unreliability of speed
benchmarks, but I could be confusing it with some other loosely
related
matter.
--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com
On Dec 17, 2006, at 6:51 PM, Sam Collett wrote:
Has anyone done any benchmarks to compare the speeds of using
different expressions? Like how much faster $("a.myclass") is than
$(".myclass") and the difference, if any, between
$("a").filter(".myclass") and $("a.myclass") etc.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/