Reading arrays, 3 methods tested, results
Mark Talluto
mark at canelasoftware.com
Wed Jul 27 16:41:22 EDT 2016
Yes.
-Mark
> On Jul 27, 2016, at 12:48 PM, Richard Gaskin <ambassador at fourthworld.com> wrote:
>
> Thanks, Mark. You know I loves me some benchmarking. :)
>
> Do all three produce the same result?
>
> - rg
>
>
> Mark Talluto wrote:
> > Thought this might be interesting to those benchmarking reads on
> > arrays. I was working to optimize one small section of code in
> > our database and found that the method I figured would be the slowest
> > ended up being the fastest. Maybe this will be helpful to others
> > doing a lot of array work.
> >
> > Macbook Pro, macOS 10.11.5
> > LiveCode 8.1 dp2
> > Data: 135k records
> >
> > (method 1) 1.36 seconds
> > --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 tRecordA[xTableID][(the keys of xRecordClusterA)]
> > end repeat
> > end repeat
> >
> >
> > (method 2) 220 ms
> > --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 tRecordA[xTableID][xRecordID]
> > end repeat
> > end repeat
> >
> >
> > (method 3) 77 ms
> > --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 tRecordA[xTableID][tRecordID]
> > end repeat
> >
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
More information about the use-livecode
mailing list