Re: [jQuery] Speed Tests
The first thing my code does is test how long it takes to run a $(.class) query, and bases the number of attempts for each test on the speed of that query (not a perfect system, but it should prevent crazy long loads on slow computers. Check the test out at: http://yehuda.jquery.com/jq_test.html Nice! Karl and Aaron, too, thanks for starting this test framework. I wonder about how sensitive the timings are to the structure of the document. This one has an id on almost every element, which is not typical. Perhaps that is making ids look slower. Notice that $(something).filter(#id) doesn't use document.getElementById but $(#id) does. In those cases, #id is almost as expensive as .class since it has to go through all the elements in the subtree. I don't think it's worth optimizing cases like div#id to make them faster. If you want fast, say #id instead. I would much rather document how to use selectors efficiently than to make jQuery larger to optimize div#id. ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Speed Tests
My results: $('body') 1.33ms 0.64ms 0.62ms $('body div') 34.38ms 34.38ms 34.06ms $('div', [jQuery('div'), jQuery('a')]) 69.06ms 68.12ms 67.82ms document.body.getElementsByTagName('div') 0ms 0ms 0ms $(jQuery.merge(document.getElementsByTagName('div'), [])) 23.12ms 23.12ms 23.44ms $('div') 32.5ms 33.12ms 32.82ms document.getElementsByTagName('div') 0ms 0ms 0ms $('*') 50.62ms 54.36ms 55.94ms document.getElementsByTagName('*') 0ms 0ms 0ms $('.dialog') 61.86ms 65.62ms 68.44ms $('div.dialog') 43.76ms 43.74ms 44.06ms $('div').filter('.dialog') 47.2ms 45ms 50.94ms $('div#speech5') 40ms 39.68ms 42.82ms $('div #speech5') 34.06ms 32.18ms 34.38ms $('#speech5', document.getElementsByTagName(div)) 0.64ms 0.62ms 0.64ms $('div').filter('#speech5') 44.06ms 40.62ms 43.76ms $('#speech5').filter('div') 0.62ms 0.64ms 0.62ms $('#speech5') 0.32ms 0.32ms 0.62ms $('body div.scene div#speech5') 49.38ms 51.56ms 55.32ms $('div.scene div.dialog') 87.18ms 87.5ms 88.44ms !//-- andy matthews web developer certified advanced coldfusion programmer ICGLink, Inc. [EMAIL PROTECTED] 615.370.1530 x737 --//- -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Yehuda Katz Sent: Tuesday, December 19, 2006 11:01 AM To: jQuery Discussion. Subject: [jQuery] Speed Tests In the vein of the discussion we've been having on this list (and, of course, heavily inspired by the first speed test), I've created a more extensive speed test that tests a bunch of similar cases. A word of warning: your browser will not be available for a good 30 seconds or so while the test is running, but it will not lock up. The first thing my code does is test how long it takes to run a $(.class) query, and bases the number of attempts for each test on the speed of that query (not a perfect system, but it should prevent crazy long loads on slow computers. Check the test out at: http://yehuda.jquery.com/jq_test.html -- Yehuda Katz Web Developer | Wycats Designs (ph) 718.877.1325 ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/
Re: [jQuery] Speed Tests
On Dec 19, 2006, at 12:51 PM, Dave Methvin wrote: The first thing my code does is test how long it takes to run a $(.class) query, and bases the number of attempts for each test on the speed of that query (not a perfect system, but it should prevent crazy long loads on slow computers. Check the test out at: http://yehuda.jquery.com/jq_test.html Nice! I agree. Good work, Yehuda! Karl and Aaron, too, thanks for starting this test framework. I wonder about how sensitive the timings are to the structure of the document. This one has an id on almost every element, which is not typical. Perhaps that is making ids look slower. Very good point. Before I threw the test page up there, I raised the same issue (rather, I recalled that the issue had been raised on the list before) about the times varying depending on page complexity. With that in mind, how about this for a more robust test page: 1. start with a simple 3-column layout, plus header and footer, and dump some lorem ipsum in for content. 2. have a form with a. text field for DOM querying, like I have on my current test page. b. textarea for additional markup, and an appendTo text field next to it. That way, you could drop in as many extra DOM elements as you want, wherever you want, and then test a query's speed. If people think this would work and would be useful, I'd be happy to build it. --Karl _ Karl Swedberg www.englishrules.com www.learningjquery.com ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/