On Tue, 29 Sep 2009, A.Yerenkow wrote:

> You could find info in internet about why is that :)
> The javascript arrays aren't arrays at all :)
> To see the whole picture, try reverse tests, like this:
>
> a) var k, n = 5000000;
>     var d=[];
>     for (k=n; k>0; k--) {
>       d[k] = k;
>     }
>
> .....
>
> d) var k, n = 5000000;
>     var d=[];
>     d[n]=n;
>     for (k=n; k>0; k--){
>       d[k] = k;
>     }
>
> e) var k, n = 5000000;
>
>     var d=[];
>     d[0]=0;
>     for (k=n; k>0; k--){
>       d[k] = k;
>     }

Oops ... about a factor 30-80 slower than the forward versions with FF
3.5.3, but "only" about a factor of 5 slower in Chrome ...

Good to know, especially as some loop optimisation suggestions I found
recommend looping downwards (which indeed might make the loop control
structure faster, but the actual code inside the loop dominating the picture
completely in this example).

Another "interesting" result:

n = 20000000;
var k, d=[];
for (k=0; k<n; k++) {
   d[d.length]=k;
}

is basically as fast as

n = 20000000;
var d = new Array(n);
var t2= new Date().getTime();
for (k=0; k<n; k++) {
   d[k] = k;
}

and about 40% faster (FF 3.5.3) and about 10% faster (Chrome) as the
push-version while doing exactly the same.  Is this due to the method call
overhead of .push() or does push() do something fancy?

I don't have a very clean setup for IE-Testing, but at first glance the
effects seem similar.

Cheers,
Fritz

-- 
Oetiker+Partner AG              tel: +41 62 775 99 03 (direct)
Fritz Zaucker                        +41 62 775 99 00 (switch board)
Aarweg 15                            +41 79 675 06 30 (mobile)
CH-4600 Olten                   fax: +41 62 775 99 05
Schweiz                         web: www.oetiker.ch

------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to