To template or to lock?
Pretty sure that setting a templateXXX to a bunch of properties is the way to go if you need to repeatedly create the same type of object, but I was wandering about one-off's? I'm looking at a community provided script - and it used the templategraphic technique to create each object - like this: 1. set the prop x of the templategraphic to n 2. set the prop y of the templategraphic to m 3. create the graphic 4. reset templategraphic In my not entirely scientific speed tests I get 168 ticks for the creation of 100 objects using this technique. As fo the technique of simple creation and locking the screenr: 1. lock the screen 2. create the graphic 3. set prop x, y, z 4. unlock the screen I get 94 ticks for the creation of 100 objects using the lock screen technique for each object creation. I guess simple creation of the object is not only a little safer (no forgetting to rest), but nearly twice as fast (which is surprising). Here are the two scripts: on mouseUp >put the ticks into startTick >set lockmessages 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 lockmessages to false >put the ticks - startTick > end mouseUp > > on mouseUp >put the ticks into startTick >set lockmessages to true >repeat 100 > lock screen > 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 > > unlock screen >end repeat >set lockmessages 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 > ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
On Sat, Feb 6, 2010 at 9:11 PM, David Bovill wrote: > Pretty sure that setting a templateXXX to a bunch of properties is the way > to go if you need to repeatedly create the same type of object, but I was > wandering about one-off's? I'm looking at a community provided script - and > it used the templategraphic technique to create each object - like this: > > 1. set the prop x of the templategraphic to n > 2. set the prop y of the templategraphic to m > 3. create the graphic > 4. reset templategraphic > > In my not entirely scientific speed tests I get 168 ticks for the creation > of 100 objects using this technique. As fo the technique of simple creation > and locking the screenr: > > 1. lock the screen > 2. create the graphic > 3. set prop x, y, z > 4. unlock the screen > > I get 94 ticks for the creation of 100 objects using the lock screen > technique for each object creation. I guess simple creation of the object is > not only a little safer (no forgetting to rest), but nearly twice as fast > (which is surprising). I would combine the 2 techniques. Before the repeat loop, set the templateGraphic's properties to those that are the same in each graphic. In the repeat loop, create the new graphic and set the properties that are different for each graphic. After the repeat loop has finished, reset the templateGraphic, but only do this once. This is untested, but would seem logically to be the most efficient method. Unless you really need to see the graphics as they are created, it will be much faster if you put a lock screen before the repeat loop starts, rather than locking & unlocking for each object. An alternative that I have used is to have a hidden object that is already set up the way I want, then just clone it instead of creating a new object from scratch. But I haven't done any benchmarks on that, since I usually only need it during development. Cheers, Sarah ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
On 6 February 2010 11:35, Sarah Reichelt wrote: > > I would combine the 2 techniques. > > Before the repeat loop, set the templateGraphic's properties to those > that are the same in each graphic. > There are no repeated properties each graphic is unique. IThe scripts quoted are just test to compare object creation speed. It is interesting to note that it is nearly twice as fast - not to use templateXXX for creation of individual objects - personally I'd have guessed it would be slightly faster or the same to set a global template than to find and set a specific object. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
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@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
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 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@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution > ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
David, OK, I get it. But funnily if you add a lock screen and unlock screen to the templategraphic repeat loop as in the repeat loop without the the templategraphic you get the same time, templategraphic does not take longer any more. I don't know why since as you said you only have one screen update in the templategraphic routine. Go figure. regards Bernd -- View this message in context: http://n4.nabble.com/To-template-or-to-lock-tp1471169p1472175.html Sent from the Revolution - User mailing list archive at Nabble.com. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
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___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
Malte Pfaff-Brill wrote: 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. That's my general rule. If I only need to create one object, I do it line by line in a script. If I need to create more than one with the same properites, I set the template object. It's pretty much the same rule I follow when deciding whether to break out handlers and functions. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: To template or to lock?
Yes - but why does locking the screen nearly double the speed in the case where you set template properties and the only actual step that draws to screen is a single one - create graphic? Locking and unlocking should surely make no difference here? on mouseUp >put the ticks into startTick >set lockmessages to true >repeat 100 > 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 lockmessages to false >put the ticks - startTick > end mouseUp > On 7 February 2010 18:52, Malte Pfaff-Brill wrote: > 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___ > use-revolution mailing list > use-revolution@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-revolution > ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution