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?

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]

///
------------------------------------------------------------------------------
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to