Chunks vs Arrays - surprising benchmarking results
Richard Gaskin
ambassador at fourthworld.com
Wed Aug 5 16:02:45 EDT 2009
Trevor DeVore wrote:
> On Aug 5, 2009, at 3:05 PM, Richard Gaskin wrote:
>
>> Any thoughts on how I might optimize the array functions? Did I
>> just overlook something obvious which would make them run faster?
>
> Richard,
>
> The main slowdown in your test for GetFromMainArray seems to be in
> transferring the data from the custom property to tDataA. This is
> consistent with my findings when implementing persistent data storage
> in the data grid.
>
> I changed the code a bit so that the field contents and uData custom
> prop array were put into script locals outside of the timers. Here is
> what I got:
>
> GetFromList: 30
> GetFromSubArray: 244
> GetFromMainArray: 27
> All results the same?: true
>
> So if your data is already in a script local then arrays seem to be
> faster.
Excellent sleuthing, Trevor. Confirmed: with that change I'm getting
the same results. Who would have thought there could be so much
overhead moving a custom property array into a variable array?
Unfortunately for my case, this data is only one of several tables
stored in user documents. I could move all the data out of the stack
file I'm using for the document into a global when the document is
opened, and could even use a master array within the global to keep the
data from different open documents separate, but that adds another layer
of management and the increase in data size for a speed gain of 0.03ms
per iteration.
I had hoped that I might be able to get around the need to copy the data
out of the properties by using array notation directly on those
properties, but alas it doesn't seem the property array syntax is yet
parallel with variable array syntax as it used to be before we got
multi-dimensional arrays.
I'll think this over, but so far the two methods are so close in
performance that I'm inclined to stick with what's in place with chunk
expressions for now.
Thanks again for finding the bottleneck in the data loading. That's
valuable info.
--
Richard Gaskin
Fourth World
Revolution training and consulting: http://www.fourthworld.com
Webzine for Rev developers: http://www.revjournal.com
More information about the use-livecode
mailing list