1 more speed question

Mark Wieder mwieder at ahsoftware.net
Thu May 19 03:00:37 EDT 2005


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? Or am I the only
one who's seeing these results?

-- 
-Mark Wieder
 mwieder at ahsoftware.net



More information about the use-livecode mailing list