To template or to lock?

BNig niggemann at uni-wh.de
Sat Feb 6 06:49:55 EST 2010


David,
I fully agree with Sarah, but even in your comparison you forgot to set the
lockscreen in the templategraphic example.
try this modification of your script and compare the times
--------------------
on mouseUp
   put the ticks into startTick
   set the lockmessages to true
   set the lockscreen to true
   repeat 100
      set the foregroundcolor of the templategraphic to colour_GetRandom()
      set the backgroundcolor of the templategraphic to colour_GetRandom()
      set the style of the templategraphic to "rectangle"
      set the linesize of the templategraphic to random (8)
      set the opaque of the templategraphic to true
      set the loc of the templategraphic to the loc of this cd
      
      create graphic "Test"
      reset templategraphic
   end repeat
   set the lockscreen to false
   put the ticks - startTick
end mouseUp

function colour_GetRandom
   put random(255) into item 1 of someColour
   put random(255) into item 2 of someColour
   put random(255) into item 3 of someColour
   return someColour
end colour_GetRandom
-------------------
in your script without the templategraphic you lock and unlock the screen
every time around in the repeat loop, without that you get about the same
speed as with the templategraphic
-----------------
on mouseUp
   put the ticks into startTick
   set lockmessages to true
   lock screen
   repeat 100
      create graphic "Test"
      put it into createdGraphic
      set the foregroundcolor of createdGraphic to colour_GetRandom()
      set the backgroundcolor of createdGraphic to colour_GetRandom()
      set the style of createdGraphic to "rectangle"
      set the linesize of createdGraphic to random (8)
      set the opaque of createdGraphic to true
      set the loc of createdGraphic to the loc of this cd
   end repeat
   set lockmessages to false
   unlock screen
   put the ticks - startTick
end mouseUp

function colour_GetRandom
   put random(255) into item 1 of someColour
   put random(255) into item 2 of someColour
   put random(255) into item 3 of someColour
   return someColour
end colour_GetRandom
--------------------------------

for both versions it takes about 3 ticks on a MacBook Pro 2.33
regards
Bernd

-- 
View this message in context: http://n4.nabble.com/To-template-or-to-lock-tp1471169p1471182.html
Sent from the Revolution - User mailing list archive at Nabble.com.



More information about the Use-livecode mailing list