From: Pascal B. <pa...@dy...> - 2001-02-24 13:18:30
|
So here I am.. trying to get the dynlayer up to speed. problem is, everything I tried was actually making things slower... until I shut down a few tools running in the background.. problem fixed. Next problem, DynLayer is a bit faster, but not as fast as the dynacore version..why is that? Well, lets try these two different speed test (you can try it now, I had a few hours before getting to this part :) slow: function run() { var start = new Date(); var a = [] for (var i=0; i<200;i++ ){ a[i] = new DynLayer(); DynAPI.document.addChild(a[i]); a[i].moveTo(i*3,i*3); a[i].setHTML(i); } var end = new Date(); alert("took " + (end.getTime()-start.getTime()) + " milliseconds."); } and "mega" fast version: function run() { var start = new Date(); var a = [] for (var i=0; i<200;i++ ){ a[i] = new DynLayer(null,null,null,10,10); DynAPI.document.addChild(a[i]); a[i].moveTo(i*3,i*3); a[i].setHTML(i); } var end = new Date(); alert("took " + (end.getTime()-start.getTime()) + " milliseconds."); } Difference? the width and height are being specified in the constuctor. And you know what, this makes the following 2 lines (Read TWO lines) not being triggered: if (this.w==null && this.getContentWidth()>0) this.setWidth(this.getContentWidth(), false); if (this.h==null && this.getContentHeight()>0) this.setHeight(this.getContentHeight(), false); and you know what, that is what fixes things. Now why does this not happen in dynacore? well, because there the this.w and this.h default value is not null but 0. I tried this in dynapi, but some widgets (label,dynimage,etc) depend on this function. So I can't really set the value to 0 as default (although I think it should) because we then need some widget cleaning (which I also think should). So for now if you want speedy dynlayers, specify atleast the width and height values it makes a difference (bigtime). I did manage to get a few other speed fixes and updates in there, so check out the CVS code... here's my CVS commit message: - speed fixed in createElement (also changed static methods back to prototype methods.. seems a bit faster.. not much though) - changed all browser if statements, there's now a new is.def browser property which is true when a default browser is used.. this includes IE and NS6/DOM.. these are now handled first and by default, which should also be faster I've also changed the addChild() method as mentioned before.. When you want to add multiple child layers at once, a function is easily created for that, so no need in making it default. Pascal Bestebroer pa...@dy... http://www.dynamic-core.net |