On 12/18/2015 06:41 PM, Robert Hanson wrote:
> Rolf, let's try some tests.  I noticed that 16 Mb of JSON code was turned
> into JavaScript in 1.5 seconds by the browser just using  a script tag, so
> that parser is fantastic.
>
> Putting that much into Jmol variables would be a challenge, and I do not
> propose to be able to do it on that scale, but even for smaller amounts it
> should be interesting. I have just implemented in JSmol the capability to
> read JavaScript objects directly into Jmol variables without using JSON.
> What I've done is to slightly change the action of
>
> y = javascript("x")
>
> Currently that just returns some sort of string equivalent -- for example
> "[Object object]" -- but what  I have just gotten working is that if x is
> something other than a string, it will be translated into a Jmol variable.
>
> Ho, ho! This just worked:
>
> x = load("tt.json")
> print x.length
>
>
> *58696197*
> y = javascript(x)
> print y.keys
>
> *edgeInfoedgeKeysUsededgeNumberToEdgeKeymaxEdgeNumbermaxNodeNumberneighboursnodeInfonodeLegendInfonodeNumberToNodeKeysubnetworkInfo*
> print y.edgeInfo.keys.length
>
>
> *51426*
> Of course, TaskManager is reporting that Firefox is using 820Mb of memory
> right now. Here it is with a timing test:
>
> x = null
> y = null
> t = now();
> x = load("tt.json")
> print "ms to read " + x.length + " bytes: " + now(t)
> t = now()
> y = javascript(x)
> print "ms to translate JSON to Jmol variables: " + now(t)
>
> ms to read 58696197 bytes: 12313
> ms to translate JSON to Jmol variables: 25286
>
> ​So that's 38 seconds to process 58.7 Mb of JSON code. OK, so that is
> probably better than you are doing now, right?
>
That sound great! Much better than 18 hours times 60.

> Rolf, if you have time, could you help me with some JavaScript time trials?
> I am interested, for example, in how much faster .slice is than straight
> copying:
>
> //given (in JavaScript)
>
> a = new Array(50000)
>
> // compare
>
> b = a.slice()
>
> // to
>
> b = new Array(50000)
> for (var i = a.length;--i >= 0;)
>    b[i] = a[i]
>
> ///
>
Bob, are you sure that the slice command really copies the array?

I did this from JSmol:

---- Jmol script -----------------------------
jsCommand = "n=1000000; t1=performance.now(); a = new Array(n); 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(); msg='slice: ' 
+ (t2 - t1) + 'ms  copy: ' + (t3 - t2) + 'ms'; alert(msg)";
javascript @jsCommand;
----------------------------------------------

The 'slice' time was independent of 'n' but dependent on the type of 
JSmol, in a reverse manner for Firefox and Chromium:
  Firefox/HTML5:  0.02ms
  Firefox/Java:   0.04ms
  Chromium/HTML5: 0.06ms
  Chromium/Java:  0.03ms

With 'copy' the time was dependent on the type of JSmol (n=1000000), but 
in a reverse manner for Firefox and Chromium:
   Firefox/HTML5:  850ms
   Firefox/Java:  4600ms
   Chromium/HTML5: 800ms
   Chromium/Java:  180ms

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:  rhue...@leibniz-fli.de
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
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to