Reading arrays, 3 methods tested, results
Richard Gaskin
ambassador at fourthworld.com
Wed Jul 27 16:52:44 EDT 2016
Mark Talluto wrote:
>> On Jul 27, 2016, at 12:48 PM, Richard Gaskin wrote:
>>
>> Thanks, Mark. You know I loves me some benchmarking. :)
>>
>> Do all three produce the same result?
>
> Yes.
I get very different results here using this script to produce a small
sample data set. I would expect them to be different given that Method
1 re-uses a single multi-line key, and Method 3 uses a multi-line key to
retrieve a value that in the original data is a simpler key.
Then again, I have to admit I'm not sure what the transformation is
supposed to do.
Where does this code go wrong?:
on mouseUp
-- Create small data set:
repeat with i = 1 to 5
repeat with j = 1 to 5
repeat with k = 1 to 5
put "val-"& i &"-"& j &"-"& k into tVal
put tVal into gCSIdatabaseA[i][j][k]
end repeat
end repeat
end repeat
-- Arbitrary ID for sub-array of interest:
put 5 into xTableID
--
--GET ALL THE RECORDS FROM THIS TABLE
repeat for each element xRecordClusterA in gCSIdatabaseA[xTableID]
repeat for each element xElement in xRecordClusterA
put xElement into tRecordA1[xTableID][(the keys of
xRecordClusterA)]
end repeat
end repeat
--GET ALL THE RECORDS FROM THIS TABLE
repeat for each element xRecord in gCSIdatabaseA[xTableID]
repeat for each key xRecordID in xRecord
put xRecord[xRecordID] into tRecordA2[xTableID][xRecordID]
end repeat
end repeat
--GET ALL THE RECORDS FROM THIS TABLE
repeat for each key xRecordCluster in gCSIdatabaseA[xTableID]
put the keys of gCSIdatabaseA[xTableID][xRecordCluster] into
tRecordID
put gCSIdatabaseA[xTableID][xRecordCluster][tRecordID] into
tRecordA3[xTableID][tRecordID]
end repeat
-- Display result:
put arrayEncode(tRecordA1) into r1
put arrayEncode(tRecordA2) into r2
put arrayEncode(tRecordA3) into r3
put ( (r1 = r2) AND (r2 = r3) ) \
&cr&cr& "Set1 len="& len(r1) &cr&"<START>"& r1 &"<END>" \
&cr&cr& "Set2 len="& len(r2) &cr&"<START>"& r2 &"<END>" \
&cr&cr& "Set3 len="& len(r3) &cr&"<START>"& r3 &"<END>"
end mouseUp
--
Richard Gaskin
Fourth World Systems
Software Design and Development for the Desktop, Mobile, and the Web
____________________________________________________________________
Ambassador at FourthWorld.com http://www.FourthWorld.com
More information about the use-livecode
mailing list