1 more speed question

Richard Gaskin ambassador at fourthworld.com
Thu May 19 03:13:59 EDT 2005


Mark Wieder wrote:
> Jacque-
> 
> Wednesday, May 18, 2005, 8:03:53 PM, you wrote:
> 
> JLG> This came up on the MetaCard list back in the dark ages. Scott Raney
> JLG> said the engine figures out the variable so we don't have to, and the
> JLG> two should be identical in speed.
> 
> Maybe I'm still in the dark ages... I wrote up a new speed test here
> and the loop that uses a variable seems to be running some 25 times
> faster than the one that evaluates the limit each time.
> 
> 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? 

I doubt it. Same engine, same interpreter/compiler.

I think it depends on the nature of the max value being used.  If it's 
something that can change, like the number of controls, it needs to be 
evaluated each time.

Or so I think, but at least it would be consistent with what you're 
seeing, and in some ways consistent with what we would expect: how 
useful would it be to have a repeat loop which could affect the number 
of controls not counting the number of controls which govern it?

--
  Richard Gaskin
  Fourth World Media Corporation
  __________________________________________________
  Rev tools and more: http://www.fourthworld.com/rev



More information about the use-livecode mailing list