DB examples corrupted? and other questions

Monte Goulding monte at sweattechnologies.com
Sun Jul 13 19:45:00 EDT 2003


> Monte Goulding wrote:
>
> > I'm wondering if you have tested multi-dimensional arrays (stored as
> > customproperty sets)? I think the direct access nature would kill
> > tab-delimited text. What abut using something like:
> primaryKey,columnName as
> > the array key? I think it could be very fast and handle much
> more data. In
> > addition there is no risk from the delimiters.
>
> True on all fronts. Random access of specific "records" (elements in an
> array and lines in text) is much faster with arrays than with one block of
> text.
>
> However, in my case I settled on chunks because in nearly every usage I'm
> displaying only a subset of columns, and usually more than one
> record, so I
> need to query the whole data set each time.  In my benchmarks walking
> through all the elements of an array is slower than walking through a text
> block.
>
> I don't have those benchmarks handy, but if I recall "repeat for each
> element" took nearly twice as long as "repeat for each line".

That's where filter and sort on array keys would come in handy.
>
> Your code:
>
> > on mouseUp
> >   put the long seconds into tSeconds
> >   set the itemDel to tab
> >   put the cTest of this stack into tTest
> >   repeat with x=0 to 10000 step 100
> >     put item 25 of line x of tTest into tData
> >   end repeat
> >   put the long seconds - tSeconds into tTest1
> >   put the long seconds into tSeconds
> >   repeat with x=0 to 10000 step 100
> >     put the cTest[x,25] of this stack into tData
> >   end repeat
> >   put the long seconds - tSeconds into tTest2
> >   put tTest1,tTest2
> > end mouseUp
> >
> > Result 0.219,0.002
>
> ...uses the "repeat with" form, which is much slower than "repeat
> for each"
> and doesn't scale well; it takes increasingly longer as you work your way
> down through the lines, as it needs to count the number of lines each time
> through the loop.  The "repeat for each line" form runs at a
> nearly constant
> rate of lines per millisecond regardless of the size of the data set.
>
> The "repeat for each" form parses and keeps its place as it goes,
> making it
> many times faster for large text blocks.
>
I knew someone would pick me up on that.

Cheers

Monte




More information about the use-livecode mailing list