03-14-2011 12:37 PM
I will explore how much time is being used by using the profiler, and see where the fat can be cut.
03-15-2011 04:29 AM - edited 03-15-2011 04:32 AM
@altenbach wrote:
[...]
As others have said, local variables typically don't cause slowdown (They cause additional datacopies in memory, have the potential of causing race conditions and cause messy code).[...]
While i totally agree with you, altenbach, creation of data copies DOES take time (variable configured for reading!), esp. if the system is already loaded and/or if the memory is already very fragmented.
So it *could* be possible, that usage of variables does induce a slowdown in addition to all other risks.....
But in most cases, the overhead for variables does not really fall into account. So everyone stating to search for other possible reasons is absolutly correct!
Just wanted to clearify this for everyone.
thanks,
Norbert
PS: Short listing of "Pace of writing":
Terminal (being fastest)
Global variable
Local Variable
VI Server method "Set Control Value"
Property node "Value" (being slowest)
03-15-2011 07:44 AM
@Norbert B wrote:
...thanks,
Norbert
PS: Short listing of "Pace of writing":
Terminal (being fastest)
Global variable
Local Variable
VI Server method "Set Control Value"
Property node "Value" (being slowest)
The order of those last two items would have been flop-flopped in my book. I'm willing to reset my memory if you can provide a reason why (or bench-marks) an operation that requires a text look-up of the "control name" can execute faster than an operation that laready has the reference.
Curious,
Ben
03-15-2011 08:19 AM - edited 03-15-2011 08:22 AM
Ben,
on my machine (Dell Latitude E6500) running Windows 7 and LV 2010f2, the property node value is about fourty times slower than using the VI Server method "Set Control Value". But there are not many controls on the panel though....
I do not know if the method gets slower in relation to the number of controls on the panel. This might reduce the difference, nevertheless i would think that "Set Control Value" is always faster than the prop node....
Norbert
The code above is about 40 times faster than this one below (beware: DEPENDENT ON MACHINE!):
03-15-2011 09:50 AM
@Norbert B wrote:
While i totally agree with you, altenbach, creation of data copies DOES take time (variable configured for reading!), esp. if the system is already loaded and/or if the memory is already very fragmented.
So it *could* be possible, that usage of variables does induce a slowdown in addition to all other risks.....
"takes time" is not the same as "causing slowdown". Unless the program is operating with huge data structures, todays computers are easily able to deal with it. So we have a few additional data copies. Another program without locals might have 10x larger data structures to begin with and still does not run slow.
Memory fragmentation problems arise if data structures constantly change size (e.g. insert into array, delete from array, built array) and that can easily be achieved without local variables. OTOH, local variables of fixed size data are typically not a problem.
We need to see the actual code to determine what the problem is.