1 more speed question
Dave Cragg
dcragg at lacscentre.co.uk
Thu May 19 05:36:42 EDT 2005
On 19 May 2005, at 10:20, Dave Cragg wrote:
>
> On 19 May 2005, at 08:00, Mark Wieder wrote:
>>
>> on mouseUp
>> local elapsedTime, x, y, z
>>
>> put the milliseconds into elapsedTime
>> put the number of controls on card id 200593 of stack "revIcons"
>> into y
>> repeat 1000 times
>> repeat with x=1 to y
>> add 1 to z
>> end repeat
>> end repeat
>> put the milliseconds - elapsedTime into field "fldResult1"
>> end mouseUp
>>
>> on mouseUp
>> local elapsedTime, x, z
>>
>> put the milliseconds into elapsedTime
>> repeat 1000 times
>> repeat with x=1 to the number of controls on card id 200593 of
>> stack "revIcons"
>> add 1 to z
>> end repeat
>> end repeat
>> put the milliseconds - elapsedTime into field "fldResult2"
>> end mouseUp
>>
>> Maybe the optimization only happens in a standalone? Or am I the only
>> one who's seeing these results?
>>
>
> Using your scripts, I'm seeing the same results. But if I change to
> "the number of controls of this card" (where the card has 250
> fields), it's very different -- similar times for both methods.
> Strange.
>
I said the times were similar when using fields on the current card,
but the first method (pre-counting the number) is always a little
faster (280 ms vs 320 ms)
On a hunch, I used images instead of fields, but still on the current
cards, and the results were similar to those for fields.
Then I put the images in a closed substack. This time, the time
difference was huge. 10 times slower for the second method.
With fields on a closed substack, the times were simialr for the
controls on the current card.
So I'm wondering, when referring to images on a closed card, whether
some buffering activity is going on whenever the card is referred to.
This, combined with the slight but consistent speed advantage of the
first method when referring to fields, makes me think we need some re-
confirmation of the notion that the "limit expression" in a repeat
loop is only evaluated once.
Dave
More information about the use-livecode
mailing list