On 12/18/2015 09:05 PM, Robert Hanson wrote:
> Oh, yes. .slice() copies all or part of an array.
>
The independence of 'n' was caused because the elements of the copied
array were all undefined. I have changed the test and filled the array
with values first:
---- Jmol script --------------------------
jsCommand = "n=1000000; a = new Array(n); for (var i = a.length;--i >=
0;) {a[i] = i;} t1=performance.now(); b = a.slice(0);
t2=performance.now(); c = new Array(n); for (var i = a.length;--i >= 0;)
{ c[i] = a[i] } t3=performance.now(); dt1= t2 - t1; dt2= t3 - t2; a[5] =
-5; msg='slice: ' + dt1 + 'ms copy: ' + dt2 + 'ms a[5]=' + a[5] + '
b[5]=' + b[5] + ' c[5]=' + c[5]; alert(msg)";
javascript @jsCommand;
---------------------------------------------
Now 'slice' also depends on 'n':
Firefox/HTML5: 4ms
Firefox/Java: 4ms
Chromium/HTML5: 10ms
Chromium/Java: 7ms
And the new values for 'copy' are:
Firefox/HTML5: 500ms
Firefox/Java: 4000ms
Chromium/HTML5: 700ms
Chromium/Java: 130ms
Bob and others, do you have any idea why there is such a huge
performance difference in running the same Javascript code from
JSmol/Java or JSmol/HTML5 and that in a different direction for Firefox
and Chrome?
Regards,
Rolf
--
Rolf Huehne
Postdoc
Leibniz Institute on Aging - Fritz Lipmann Institute (FLI)
Beutenbergstrasse 11
07745 Jena, Germany
Phone: +49 3641 65 6205
Fax: +49 3641 65 6210
E-Mail: [email protected]
Website: http://www.leibniz-fli.de
Scientific Director: Prof. Dr. K. Lenhard Rudolph
Head of Administration: Dr. Daniele Barthel
Chairman of Board of Trustees: Burkhard Zinner
VAT No: DE 153 925 464
Register of Associations: No. 230296, Amtsgericht Jena
Tax Number: 162/141/08228
------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users