Page 1 of 1

lock group updates

Posted: Tue Apr 23, 2013 1:17 pm
by monte
Hi

mApp the mobile app framework I've been working on has code that sets the rect of all objects on a card in a recursive handler. It occurs to me there's probably lots of wasted execution time on groups resizing themselves and resetting scrollbars when each of their children is resized. I think for such a situation a way to lock a group from refreshing itself on MCGroup::resizeparent() and a way to unlock it thus causing resizeparent to happen once at the end would improve performance significantly... what do others think about the idea? Note that lockLocation actually doesn't stop quite a bit of code executing ...

Code: Select all

set the lockUpdates of group 1 to true
-- code that changes lots of child object locations
set the lockUpdates of group 1 to false
Cheers

Monte

Re: lock group updates

Posted: Mon Apr 29, 2013 10:55 am
by monte
Hi... not much interest in this obviously

I had a little play with it anyway and the following code moving an object inside a group was about twice as fast with lockUpdates true than if the lockUpdates lines are commented out. On average about 8 ms with lockUpdates and 17 ms without. Not sure if it's worth the trouble but I guess if we are looking at game engines then any object movement optimisations we can provide the better.

Code: Select all

on mouseUp
   lock screen
   put the milliseconds into tSecs
   set the lockUpdates of the owner of btn "test" to true
   repeat 1000
      set the loc of btn "test" to random(the width of this cd),random(the height of this cd)
   end repeat
   set the lockUpdates of the owner of btn "test" to false
   put the milliseconds - tSecs
end mouseUp

Re: lock group updates

Posted: Mon Apr 29, 2013 11:04 am
by monte
Oh, and it's about 5 times faster if lock screen isn't on (around 200ms v 1000ms)... but I didn't think that would count because if you care enough about performance to lockUpdates then leaving the screen unlocked would be odd...

Re: lock group updates

Posted: Mon Apr 29, 2013 11:10 am
by monte
Interesting... I tried with scrollbars visible thinking it would be better performance again and the lockUpdate version was about the same but without lockUpdates was 4 ms faster than without scrollbars...

Re: lock group updates

Posted: Mon Apr 29, 2013 11:57 am
by malte
Lots of interest monte. :-)

Re: lock group updates

Posted: Mon Apr 29, 2013 12:04 pm
by monte
OK then.. so you think shaving 8 or 9 milliseconds on 1000 object moves for objects inside a group is worth the trouble? Actually it wasn't much trouble... I guess if we're talking games then 8 or 9 milliseconds is the difference between keeping up with the frame rate and not...

Re: lock group updates

Posted: Mon Apr 29, 2013 12:12 pm
by dave_probertGA6e24
I can't really comment usefully on the subject Monte, but I, for one, am interested in your comments and what you are doing.
It sounds really good that you are looking at ways to speed up LC over and above the current improvements. Keep persevering and I'm sure everyone will appreciate it.

Cheers,
Dave

Re: lock group updates

Posted: Mon Apr 29, 2013 12:17 pm
by monte
Actually some more playing with this and for some reason it takes the same amount of time for the script to move an object that isn't grouped as it does without lockUpdates... I can't imagine why... anyway... with the change it seems it's actually faster to have your objects in groups than not. I guess grouping is handy for layers etc in games...

Re: lock group updates

Posted: Mon Apr 29, 2013 1:13 pm
by malte
Hi Monte,

every millisecond counts. In any application that works with many objects. One example as you said is games, where you do not only do this once, but repeately over and over again. There are other apps I can think of (realtime graphs for example) where the drawing time might be brought down quite a bit.

Cheers,

Malte

Re: lock group updates

Posted: Mon Apr 29, 2013 1:33 pm
by monte
Right... I guess there could easily be many objects in a complex chart and I like charts that move when you fiddle with sliders etc so it would smooth out that too I guess...

Re: lock group updates

Posted: Wed May 01, 2013 11:17 am
by monte
Just bumping this to see if @runrevmark has comments.. I can send a pull request if you want to see what I've done...

Re: lock group updates

Posted: Thu May 02, 2013 11:14 am
by LCMark
I need to do some more thinking on this one - I can see the utility (particularly with the rise in custom controls which have to manipulate lots of controls inside them). If you send a pull request I can perhaps more easily see how you've got it working and thus see if it could cause any issues.

Re: lock group updates

Posted: Thu May 02, 2013 11:49 am
by monte
sent

Your message contains 4 characters. The minimum number of characters you need to enter is 10.