To template or to lock?

David Bovill david.bovill at gmail.com
Sun Feb 7 12:36:53 EST 2010


Hmmm... I'm obviously not communicating this very well. I know these scripts
can be improved - but they are designed to compare like for like, and answer
which of the two techniques is the most efficient for creating a unique
object  - in this case a graphic object. The repeat loop is only in these
examples to allow for them to be timed as otherwise they would be too fast.

The result is that it seems to be a lot faster to create an object and
adjust its properties (having locked the screen) - than to use the
equivalent template option!

There is no need to lock/unlock the srcreen with the template example as
there is only one step that draws to screen - "create graphic"

On 6 February 2010 11:49, BNig <niggemann at uni-wh.de> wrote:

>
> 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.
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>



More information about the use-livecode mailing list