To template or to lock?

Malte Pfaff-Brill revolution at derbrill.de
Sun Feb 7 13:52:41 EST 2010


Hi,

a bit late to the party, but I think I´ll throw in my observations anyway.

The locking of the screen is a crucial part of the equotation. What takes the most time (in a standalone application, getting back to this later) is the screen refresh after anything that affects a "visual" property of a control. So if you you set properties without the screen locked, this can take significantly longer than using the template*youNameTheControl*. If the screen is not locked there, it needs to be redrawn for each setting of a property. If the screen is locked the screen will be redrawn only once, as soon as an unlock screen happens, or the handler ends (for the record, adding unlock screen at the end of the handler instead of letting the engine figure it out is slightly faster than letting the engine do it). However, this comparison is not really fair. It gets fair, as soon as you set the properties of the templat*whatEverControl* with a locked screen. If you do that, I could not measure any real difference between the two methods. Now getting back to why I wrote "in a standalone application" earlier. In the IDE you will get a huge speed penaltie for all the IDE messages that are being sent, once a control is created. This is even costier than the screen refresh. So for optimal performance in the IDE I would lock screen, and if possible also lock messages. If you use the template*whatever* then or set properties, is a matter of taste if you go for a one object creation. If you need to create more than one object, then the template has the advantage of being able to producing a few lines less code under some circumstances.

 Just 2 cents,

Malte


More information about the use-livecode mailing list