Improving my test with the comments that you guys made, I first made it run twice, once with without Event.observe, and then with Event.observe. Both use non-anonymous events now as well in case that had any effect. I also removed the silly browser identification since Thomas probably has a much better computer than I do. There seems to be some variance between runs, but this is still helpful in understanding what's going on.
Under Firefox, I get the following times (http://igargoyle.com/tests/ ie_proto_event_observe_is_slower/test2.html) Total time: 0:0:610 [without Event.observe call] Total time: 0:0:625 [without Event.observe call] Total time: 0:0:625 [without Event.observe call] Total time: 0:2:125 [with Event.observe call] Total time: 0:2:453 [with Event.observe call] Total time: 0:1:953 [with Event.observe call] Likewise, in IE 7 (I don't have 6 on my laptop, please post your results): Total time: 0:0:281 [without Event.observe call] Total time: 0:0:281 [without Event.observe call] Total time: 0:0:281 [without Event.observe call] Total time: 0:8:531 [with Event.observe call] Total time: 0:8:765 [with Event.observe call] Total time: 0:8:641 [with Event.observe call] Actually got an improvement on the basic DOM creation, but the Event.observe accounted for approximately a 3x increase. So taking "Tom" 's advice to use "new Element('div',{className : "dot"});" (very cool, cheers), I get the following times: Firefox (http://igargoyle.com/tests/ie_proto_event_observe_is_slower/ test3.html) Total time: 0:0:719 [without Event.observe call] Total time: 0:0:766 [without Event.observe call] Total time: 0:0:750 [without Event.observe call] Total time: 0:3:578 [with Event.observe call] Total time: 0:3:422 [with Event.observe call] Total time: 0:2:953 [with Event.observe call] Internet Explorer: Total time: 0:0:672 [without Event.observe call] Total time: 0:0:765 [without Event.observe call] Total time: 0:0:766 [without Event.observe call] Total time: 0:2:719 [with Event.observe call] Total time: 0:2:703 [with Event.observe call] Total time: 0:2:485 [with Event.observe call] Also, since there are so many Tom's on this mailing list, just call me "nym". Hope these tests are helpful in improving prototype. Is this a (much) better test now? nym On Aug 9, 10:27 am, Tobie Langel <[EMAIL PROTECTED]> wrote: > Just to clarify a couple of things, here's how new Element works: > > 1. we use document.createElement the first time its called, extend the > generated element and cache it. > 2. when you create a second element with the same tag name, we just > clone the cached element. > > The IE "technique" you are referring to is just a special casing for > IE 's poor handling of the name attribute. > > Hope this helps, > > Regards, > > Tobie > > 2. we store a cloned Extended version of t > On Aug 9, 8:06 am, Tom Gregory <[EMAIL PROTECTED]> wrote: > > > It would. Although again I disagree with your conclusion as to why. > > (But it does reinforce my previous assertion that most of the > > slowdown you were seeing was due to element creation.) > > > The prototype DOM builder uses a technique unique to IE to create the > > elements (in IE only), which (being similar to the innerHTML solution > > which has been proven to be decently fast in IE), is much faster than > > document.createElement. > > > I don't buy the "slowness caused by extending" argument, because a) > > it didn't go away in your new test, and yet you saw speedup, and b) > > Prototype's DOM builder (i.e. new Element) extends elements too. > > > Oh, ... and there are too many Tom's on this thread. Some of you > > will have to change your name. =) > > > TAG > > > On Aug 9, 2007, at 1:05 AM, Tom wrote: > > > > I believe the slowness is caused by the speed (or lack thereof) of > > > extending each element during the call to Event.observe (element=$ > > > (element)) in IE. Using the new DOM Builder functionality in the trunk > > > branch (http://www.prototypejs.org/2007/5/12/dom-builder) and > > > replacing > > > > var el=document.createElement("div"); > > > el.className = "dot"; > > > > with > > > > var el = new Element('div',{className : "dot"}); //Uses the > > > DOM Builder functionality to create the element already extended > > > > brings the speeds of the browsers much closer together > > > > Tom --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
