Forums > MaxMSP

UI objects and efficient coding

July 8, 2012 | 6:45 pm

I’ve tried to avoid UI objects as much as possible since I started patching -expecting my patches to grow to a point where I’m pushing performance limits at some stage.

But I’m creating a lot of subpatchers and abstractions that need options to be set, and it would be great if they could have userinterface elements which may be made visible (by using bpatcher) or hidden when they are pre-set with arguments.

My question is: when a UI object is hidden in an abstraction, is it still costing more CPU time than a non-UI object?
is it different whether it is a subpatcher or an abstraction/

Thanks!!
Bas


July 8, 2012 | 7:29 pm

In most GUI environment, a graphical object is sent an event when it should redraw itself. This will happen when the visibility of the object change to "show", or if it was partially covered and then uncovered. If the visible aspects of the object itself are changed programmatically, then it will be "invalidated" which will then cause a redraw event to be triggered. However, that redraw should not happen while the object is not visible. If max objects behave this way, then there should be little or no impact on the system when the objects are hidden.
The other factor that affects this is when the work gets done so that the object knows what has to be drawn. If update data is just stored when it changes and the calculations for redrawing don’t happen until the object actually redraws itself, then the impact of hidden GUI objects should be negligible.


July 9, 2012 | 11:03 pm

Thanks dhjdhjdhj, I think you are saying ‘it shouldn’t matter al long as the UI object is not in any open window’ right?


July 9, 2012 | 11:10 pm

IF they implemented UI objects this way THEN it shouldn’t matter.


July 10, 2012 | 12:15 am

Turn on the metro and look at CPU use in Task Manager or Activity Monitor with the patch below.

Then encapsulate all the buttons

– Pasted Max Patch, click to expand. –

July 10, 2012 | 10:47 am

Nuff said! Thanks Andrew, that is superclear.


July 10, 2012 | 11:44 pm

by the way Andrew, is there no way to have a look at Max’s non audio object cpu utilization from within MaxMSP ? If not, is there a specific reason as to why ?


Viewing 7 posts - 1 through 7 (of 7 total)