[mochikit] Re: Selector speedup by using John Resig's Sizzle
On Mon, Oct 20, 2008 at 17:40, John Resig <[EMAIL PROTECTED]> wrote: >> I don't know what other MochiKitters say about including Sizzle.js as >> a seperate file. Per, Bob? > > So it seems like the major difference is that your selector method > (findChildElements) is able to take an array of results, correct? Yes, correct. This is something we inherited from Prototype, from where the current Selector module was ported. Perhaps we should change the API, I don't know.. cheers, Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
> Well, that makes a big difference :) Now both MK+Sizzle and Sizzle > standalone do the benchmark in 53 ms. > > John, this is an interesting testament to your implementation: > > On FF 3.1b1 with jit turned OFF the Sizzle selector code (i.e not > using querySelectorAll) completes in 55ms. > With jit turned ON *and* using the querySelectorAll - it improves only > a tiny bit to 53ms :) Ha! I certainly won't complain with those types of numbers. It's funny, I was struggling to find out why some of my selectors were slower when qSA was supposed to be used - I didn't realize that it was a product of how the test suite was working (it always passes in the extra document argument) and how the perf suite works (it doesn't pass in document). Oh well, all better now! --John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
> Actually, I copied the contents of Sizzle into Selector.js which is > part of MochiKit [1]. Integrating is then just a matter of calling > Sizzle(...) in the correct place in the Selector API. Our plan is to > completely remove the old Selector implementation, i.e. using Sizzle > won't be optional like it looks like your plan for jQuery is. It's only going to be optional during this development process - I'm planning on integrating it (and making it mandatory) in the upcoming jQuery 1.3 release. > [1] > http://trac.mochikit.com/browser/mochikit/branches/selector_sizzle/MochiKit/Selector.js > > I don't know what other MochiKitters say about including Sizzle.js as > a seperate file. Per, Bob? So it seems like the major difference is that your selector method (findChildElements) is able to take an array of results, correct? --John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Hi again, On Mon, Oct 20, 2008 at 17:01, John Resig <[EMAIL PROTECTED]> wrote: > Wow, thanks for catching that. That's amusing that it was still so > fast without using querySelectorAll, in that case. Just committed the > fix: > http://github.com/jeresig/sizzle/commit/6239a25918f8fd7d56fc97c22815418833a64e00 Well, that makes a big difference :) Now both MK+Sizzle and Sizzle standalone do the benchmark in 53 ms. John, this is an interesting testament to your implementation: On FF 3.1b1 with jit turned OFF the Sizzle selector code (i.e not using querySelectorAll) completes in 55ms. With jit turned ON *and* using the querySelectorAll - it improves only a tiny bit to 53ms :) cheers, Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Hi John, On Mon, Oct 20, 2008 at 17:19, John Resig <[EMAIL PROTECTED]> wrote: > Excellent list - I just integrated virtually all of your points: > http://github.com/jeresig/sizzle/commit/93e33dc2a41e2b0aa0e1e1c66368f5d224da80e1 Excellent. Thanks! > The exception is :visible and :hidden - which should be handled by the > host library. I agree. > Also, I wrapped the entireity of Sizzle withing a (function(){ ... > })() which means that no global variables are exposed (save for > Sizzle). > > What specific code do you use to hook Sizzle in to your engine? What > I'll probably do is just hook it directly in to the right spot (for > example, overwrite jQuery.find, in the case of jQuery) rather than > introduce a new global variable. Actually, I copied the contents of Sizzle into Selector.js which is part of MochiKit [1]. Integrating is then just a matter of calling Sizzle(...) in the correct place in the Selector API. Our plan is to completely remove the old Selector implementation, i.e. using Sizzle won't be optional like it looks like your plan for jQuery is. [1] http://trac.mochikit.com/browser/mochikit/branches/selector_sizzle/MochiKit/Selector.js I don't know what other MochiKitters say about including Sizzle.js as a seperate file. Per, Bob? cheers, Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Excellent list - I just integrated virtually all of your points: http://github.com/jeresig/sizzle/commit/93e33dc2a41e2b0aa0e1e1c66368f5d224da80e1 The exception is :visible and :hidden - which should be handled by the host library. Also, I wrapped the entireity of Sizzle withing a (function(){ ... })() which means that no global variables are exposed (save for Sizzle). What specific code do you use to hook Sizzle in to your engine? What I'll probably do is just hook it directly in to the right spot (for example, overwrite jQuery.find, in the case of jQuery) rather than introduce a new global variable. --John On Mon, Oct 20, 2008 at 10:51 AM, Arnar Birgisson <[EMAIL PROTECTED]> wrote: > Hi again, > > On Mon, Oct 20, 2008 at 16:43, John Resig <[EMAIL PROTECTED]> wrote: >> Just to clarify: Are you turning on JIT in 3.1? > > JIT is off. > >> Do you have a diff of any change(s) that you've made to your copy of Sizzle? > > Yup. http://www.hvergi.net/arnar/public/sizzle/diff.txt > > cheers, > Arnar > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Wow, thanks for catching that. That's amusing that it was still so fast without using querySelectorAll, in that case. Just committed the fix: http://github.com/jeresig/sizzle/commit/6239a25918f8fd7d56fc97c22815418833a64e00 --John On Mon, Oct 20, 2008 at 10:47 AM, Per Cederberg <[EMAIL PROTECTED]> wrote: > Of course, FF 3.1 includes querySelectorAll: > > http://ejohn.org/blog/queryselectorall-in-firefox-31/ > > And in fact, there is a slight bug in Sizzle here, causing it to not > use that version when not sending in an explicit 2:nd argument: > >Sizzle("...", document) > > The problem is here: > > if ( document.querySelectorAll ) (function(){ >var oldSizzle = Sizzle; > >Sizzle = function(query, context, extra){ >if ( context === document ) { >try { >return makeArray(context.querySelectorAll(query)); >} catch(e){} >} > >return oldSizzle(query, context, extra); >}; > >Sizzle.find = oldSizzle.find; >Sizzle.filter = oldSizzle.filter; > })(); > > Cheers, > > /Per > > On Mon, Oct 20, 2008 at 4:05 PM, Arnar Birgisson <[EMAIL PROTECTED]> wrote: >> >> Hi John, >> >> On Mon, Oct 20, 2008 at 15:52, John Resig <[EMAIL PROTECTED]> wrote: >>> That's... odd. Are there any selectors that are noticeably faster? >> >> Yes, it seems that nested queries are to blame. By nested queries I >> mean queries that uses the axis combinator, either the implicit >> "descendant" axis (like "div p") or an explicit axis combinator such >> as ~, > or +. >> >> "div ~ p" is 2ms on MK+Sizzle vs. 13ms on Sizzle. >> "div p" is 2ms on MK+Sizzle vs. 4ms on Sizzle. >> "div > p" is 1ms vs. 3ms >> "div + p" is 1ms vs. 5ms >> "div p a" is 1ms vs. 8ms >> >> Also, a[href][lang][class] is 1ms vs. 9ms. >> >>> Maybe something is failing? >> >> I don't think so, at least the number of elements returned by each is >> the same in every test. >> >> You can run the test benchmark yourself here: >> http://www.hvergi.net/arnar/public/sizzle/speed/ >> >> cheers, >> Arnar >> >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Hi again, On Mon, Oct 20, 2008 at 16:43, John Resig <[EMAIL PROTECTED]> wrote: > Just to clarify: Are you turning on JIT in 3.1? JIT is off. > Do you have a diff of any change(s) that you've made to your copy of Sizzle? Yup. http://www.hvergi.net/arnar/public/sizzle/diff.txt cheers, Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Of course, FF 3.1 includes querySelectorAll: http://ejohn.org/blog/queryselectorall-in-firefox-31/ And in fact, there is a slight bug in Sizzle here, causing it to not use that version when not sending in an explicit 2:nd argument: Sizzle("...", document) The problem is here: if ( document.querySelectorAll ) (function(){ var oldSizzle = Sizzle; Sizzle = function(query, context, extra){ if ( context === document ) { try { return makeArray(context.querySelectorAll(query)); } catch(e){} } return oldSizzle(query, context, extra); }; Sizzle.find = oldSizzle.find; Sizzle.filter = oldSizzle.filter; })(); Cheers, /Per On Mon, Oct 20, 2008 at 4:05 PM, Arnar Birgisson <[EMAIL PROTECTED]> wrote: > > Hi John, > > On Mon, Oct 20, 2008 at 15:52, John Resig <[EMAIL PROTECTED]> wrote: >> That's... odd. Are there any selectors that are noticeably faster? > > Yes, it seems that nested queries are to blame. By nested queries I > mean queries that uses the axis combinator, either the implicit > "descendant" axis (like "div p") or an explicit axis combinator such > as ~, > or +. > > "div ~ p" is 2ms on MK+Sizzle vs. 13ms on Sizzle. > "div p" is 2ms on MK+Sizzle vs. 4ms on Sizzle. > "div > p" is 1ms vs. 3ms > "div + p" is 1ms vs. 5ms > "div p a" is 1ms vs. 8ms > > Also, a[href][lang][class] is 1ms vs. 9ms. > >> Maybe something is failing? > > I don't think so, at least the number of elements returned by each is > the same in every test. > > You can run the test benchmark yourself here: > http://www.hvergi.net/arnar/public/sizzle/speed/ > > cheers, > Arnar > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Just to clarify: Are you turning on JIT in 3.1? Do you have a diff of any change(s) that you've made to your copy of Sizzle? --John On Mon, Oct 20, 2008 at 10:05 AM, Arnar Birgisson <[EMAIL PROTECTED]> wrote: > Hi John, > > On Mon, Oct 20, 2008 at 15:52, John Resig <[EMAIL PROTECTED]> wrote: >> That's... odd. Are there any selectors that are noticeably faster? > > Yes, it seems that nested queries are to blame. By nested queries I > mean queries that uses the axis combinator, either the implicit > "descendant" axis (like "div p") or an explicit axis combinator such > as ~, > or +. > > "div ~ p" is 2ms on MK+Sizzle vs. 13ms on Sizzle. > "div p" is 2ms on MK+Sizzle vs. 4ms on Sizzle. > "div > p" is 1ms vs. 3ms > "div + p" is 1ms vs. 5ms > "div p a" is 1ms vs. 8ms > > Also, a[href][lang][class] is 1ms vs. 9ms. > >> Maybe something is failing? > > I don't think so, at least the number of elements returned by each is > the same in every test. > > You can run the test benchmark yourself here: > http://www.hvergi.net/arnar/public/sizzle/speed/ > > cheers, > Arnar > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Hi John, On Mon, Oct 20, 2008 at 15:52, John Resig <[EMAIL PROTECTED]> wrote: > That's... odd. Are there any selectors that are noticeably faster? Yes, it seems that nested queries are to blame. By nested queries I mean queries that uses the axis combinator, either the implicit "descendant" axis (like "div p") or an explicit axis combinator such as ~, > or +. "div ~ p" is 2ms on MK+Sizzle vs. 13ms on Sizzle. "div p" is 2ms on MK+Sizzle vs. 4ms on Sizzle. "div > p" is 1ms vs. 3ms "div + p" is 1ms vs. 5ms "div p a" is 1ms vs. 8ms Also, a[href][lang][class] is 1ms vs. 9ms. > Maybe something is failing? I don't think so, at least the number of elements returned by each is the same in every test. You can run the test benchmark yourself here: http://www.hvergi.net/arnar/public/sizzle/speed/ cheers, Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
That's... odd. Are there any selectors that are noticeably faster? Maybe something is failing? --John On Mon, Oct 20, 2008 at 6:07 AM, Arnar Birgisson <[EMAIL PROTECTED]> wrote: > Hi all, > >> On Tue, Aug 26, 2008 at 13:38, Chris Lee-Messer >>> p.s. I'm running firefox 3.1pre now with the JIT running, and >>> slickspeed tests are interesting as your version of MochiKit.Selector >>> is reported as faster than Sizzle: most of the response times are 1ms >>> for a total time of 45ms vs 174ms for Sizzle itself. I would guess >>> that some compiled code is being cached. MochiKit's current Selector >>> comes in with a time of 4045ms. > > I just upgraded to FF 3.1b1 and I'm seeing this strange thing. For me, > MochiKit trunk completes in 1893ms, MochiKit w/Sizzle in 54ms but > Sizzle itself in ~100ms - no matter if it is run before or after the > MochiKit/Sizzle combo. > > So, MochiKit+Sizzle is almost twice as fast as Sizzle standalone. > > John, can you think of a good reason for this? > > cheers, > Arnar > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---
[mochikit] Re: Selector speedup by using John Resig's Sizzle
Hi all, > On Tue, Aug 26, 2008 at 13:38, Chris Lee-Messer >> p.s. I'm running firefox 3.1pre now with the JIT running, and >> slickspeed tests are interesting as your version of MochiKit.Selector >> is reported as faster than Sizzle: most of the response times are 1ms >> for a total time of 45ms vs 174ms for Sizzle itself. I would guess >> that some compiled code is being cached. MochiKit's current Selector >> comes in with a time of 4045ms. I just upgraded to FF 3.1b1 and I'm seeing this strange thing. For me, MochiKit trunk completes in 1893ms, MochiKit w/Sizzle in 54ms but Sizzle itself in ~100ms - no matter if it is run before or after the MochiKit/Sizzle combo. So, MochiKit+Sizzle is almost twice as fast as Sizzle standalone. John, can you think of a good reason for this? cheers, Arnar --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "MochiKit" group. To post to this group, send email to mochikit@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/mochikit?hl=en -~--~~~~--~~--~--~---