02-14-2011 12:05 PM
Hi, All,
I'd like to get people's opinion. This thought just occurred to me while I was reading some material the other day.
And I didn't find any topic specifically talking about the speed after searching the forum.
Is it faster to initialize your controls/indicators using Invoke node OR directly write initial value your local variables ?
From my personal experience (not extensive), I've always used the invoke node to initialize controls or indicators.
But when I though of this question, I did a simple benchmark and it seems the local variable approach is faster, especially
if you have large number of controls/indicators to initialize.
Am I missing something here ? Does the invoke node execute something that writing a value to local variable wouldn't do ?
I figured since you have to define the default initial state for the invoke node anyway, why not just write the desired initial value
to your local variables ?
I'd appreciate it if someone can express their own opinion based on their experience/knowledge.
Thanks ~~
Solved! Go to Solution.
02-14-2011 12:26 PM
LV users love their locals, so a fair amount of effort seems to have been spent making them perform as efficiently as possible. The cost is an extra data buffer per local. Sometimes a big deal, sometimes not. The Value Property Node, like all property nodes gets funneled through the UI thread so all updates get queued up and processed sequentially. As you noticed, for large numbers of controls this can be slower. Perhaps I should say "...for LARGE numbers..."
My own experience leads to a somewhat ironic answer. When I reach the point where locals would noticably outperform PNs, I am almost always going to use the Property Node. Why? Because I am too lazy or too vain to drop a large number of local variables onto a block diagram. I will instead use a programmatic approach utilizing Property Nodes to initialize values. Slower? In theory. Scalable? Yes! Resuable? Yes!
02-14-2011 01:07 PM
The Value Property Node, like all property nodes gets funneled through the UI thread so all updates get queued up and processed sequentially. As you noticed, for large numbers of controls this can be slower.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Darin,
You keep referring to the Value Property Node. Are you saying that the Invoke Node(Reinitialize to default method) has the same
characteristic as a Value Property Node ? I just want to clarify this.
02-14-2011 01:14 PM
@chad_vi wrote:
The Value Property Node, like all property nodes gets funneled through the UI thread so all updates get queued up and processed sequentially. As you noticed, for large numbers of controls this can be slower.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Oops. My bad. The 'Reinitialize to Default' method should also run through the UI thread but I would have expected it to be fast. I was thinking of the case where you read value from a configuration file and set initial values that are not necessarily those saved to the VI as default.
If that Method works for you, it would have to be MUCH slower for me to forsake it for local variables. What kind of time differences did you see in benchmarking?
02-14-2011 01:46 PM - edited 02-14-2011 01:48 PM
If that Method works for you, it would have to be MUCH slower for me to forsake it for local variables. What kind of time differences did you see in benchmarking?
---------------------------------------------------------------
With one numeric control, one string control, and one boolean control, I'm getting 6ms for using invoke nodes and
apparently less than ms when directly wire value to local variables ? I'm starting to think my benchmarking method
is perhaps incorrect ? Here is how I did it.
Comparing with subsituing local variables with invoke nodes in the middle frame.
02-14-2011 02:05 PM
I may need another cup of coffee this morning, you are actually callling the Reinitialize to Default on each individual control. My latest misconception is that you were using the VI Method Default Vals.Reinitialize All to Default. That will probably be a bit faster than using the method on individual controls. Still not instant, though.
Are the few msec worth it to you? If so, and you consider going the local route, my advice is to bundle as many controls as possible into clusters to minimize you headaches.
02-14-2011 02:40 PM
My latest misconception is that you were using the VI Method Default Vals.Reinitialize All to Default.
------------------------------------------------------
I may give this a try for my next project. I did not know there is a VI method to initialize ALL values within
a VI.
Are the few msec worth it to you?
------------------------------------------------------
No. I'm not specifically concern about the msecs now, although I'm getting myself into a more complex and larger
application soon. The whole point of my original post is to gain more in-depth knowledge about LabView. Things they
don't explictly show you in the books or presentations.
Thanks for all your inputs so far !!!![]()
02-14-2011 03:18 PM - edited 02-14-2011 03:19 PM
I don't remember if this is applicable to indicators, or just controls, but there are methods for the VI class called Control Value.Get All and Control Vaue.Set.
You can probably similar methods (if they exist) to programmatically read/write your indicators if there are a lot of them.
There is also an OpenG VI available that can save and load values from the front panel into INI files (in XML format) so they can be parsed out automatically as well.
02-14-2011 03:58 PM
There is also an OpenG VI available that can save and load values from the front panel into INI files
--------------------------------------------------
Cool. I'll check out OpenG. Thanks.
02-14-2011 06:07 PM
@chad_vi wrote:
There is also an OpenG VI available that can save and load values from the front panel into INI files
--------------------------------------------------
Cool. I'll check out OpenG. Thanks.
If this is your first time using OpenG, check out the installing tutorial.