11-24-2005 06:10 AM
11-24-2005 09:54 AM
The simple answer to your basic question is; the local
variable is actually more efficient than the Value property.
Of course there is a qualifier for that. The local variable is better because
using any
property of a property node causes that LabVIEW execution
engine to instantly switch to the user interface thread so the front
panel item
can be immediately updated with whatever property is being written to
it. This
can cause you application to run much slower if you are constantly
writing to
the node. You can prove this by running the attached VI (saved in
LabVIEW 6.1 for
everybody’s convenience ) So if all you're writing is the
Value, you're better off with the Local. But if you are also updating
other properties at the same time as the Value, you might as well use
the property node because you're going take the hit anyway.
Since you mention that you are using a state machine, there's a way to
avoid using locals or properties to update the value from different
locations. Make a state named "Update Display". Place the indicators
that need to updated from different locations in this case and have
them read the value from your "cluster of
"global-ish" variables". Update the cluster element from where ever you
need to and send the state machine to the Update Display state and
everything gets updated with just a wire. The overhead involved in
bundling and un-bundling a cluster is minimal. I use this in almost
every state machine I build and it really works well.
Ed
11-24-2005 10:17 AM
11-24-2005 10:42 AM - edited 11-24-2005 10:42 AM
Message Edited by Ed Dickens on 11-24-2005 10:43 AM
11-24-2005 10:46 AM
11-24-2005 11:15 AM
11-24-2005 11:55 AM
@Ed Dickens wrote:
Isn't it interesting that the local seems faster than wiring direct!? ...
Ed,
Isn't the appearance of the local being faster (at least in this example) just due to dataflow and having a couple of different 'Tick Counts' in use?
11-24-2005 12:12 PM
Partially, that's why I made the comment about moving each loop to a separate VI and running them individually so they don't fight for CPU time.Ed,
Isn't the appearance of the local being faster (at least in this example) just due to dataflow and having a couple of different 'Tick Counts' in use?
11-24-2005 03:26 PM
I modified your testing VI a bit to make it more realistic (LabVIEW 7.0). Just writing a local varaible is cheap.
Let's look at the case where we need to increment a variable in a loop. The attached demo shows 4 different ways:
Only version 4 is reasonable in such a fast, nearly empty loop and is over an order of magnitude faster than even 2 or 3. Locals and properties always update the control, something that is not desired in a fast loop. Only if the loop is slow, we might want to update during the loop, and in this case the speed penalty is insignificant.
However if we are dealing with large data structures, the extra data copies of local variables will pose a heavy performance penalty, you might even run out of memory!
Notice that the situation dramatically changes if you set the indicators to "synchronous display". Now cases 1,2,and 3 are all similar, very slow, and roughly at the property node speed (Actually, 3 is slightly faster than 1 or 2 here!!!). Only 4 is still fast as before.
11-24-2005 03:37 PM
Case (6) seems to be 20% slower than (5). Mix&Match and test... 😄