08-23-2019 06:29 AM
Hi, i wanna to know about local variables implementation. Is local variable effect the speed of program? if yes then what we will use instead of local variables? Any suggestion
08-23-2019 06:36 AM
Hi sam,
Is local variable effect the speed of program?
Well, local variables are considered as "fast". But speed depends on the amount of data you want to transfer…
if yes then what we will use instead of local variables? Any suggestion
Wires!
Globals variables :-), queues, notifier, channels, network communication including shared variables and streams, …
08-23-2019 06:46 AM
... and, if we are talking about While loops and For loops, Shift Registers ...
Bob "The Wires are the Data" Schor
08-23-2019 08:04 AM
@sam67 wrote:
Hi, i wanna to know about local variables implementation. Is local variable effect the speed of program? if yes then what we will use instead of local variables? Any suggestion
No, but they're bad style and tend to cause race conditions (as they're often misused). As already mentioned, WIRE!, queues, events and similar. 🙂
/Y
08-23-2019 08:11 AM
@sam67 wrote:
Hi, i wanna to know about local variables implementation. Is local variable effect the speed of program? if yes then what we will use instead of local variables? Any suggestion
Performance was one of my early interests when learning LabVIEW.
I earned a the bronze medal in The Dictionary challenge and one time found a corner case where my code actually performed better than Christians code!
It was one time mind and it was a corner case. Never beat him since and I have stopped trying. What is the line by the Who?
I give my crown to him. How do you think he does it? I don't know. What makes him so good?"
In order to help others learn about performance I have a collection of tags to threads that touched on the topic.
You can find those tags here.
Ben
08-23-2019 12:36 PM
@Ben wrote:
SpoilerI earned a the bronze medal in The Dictionary challenge and one time found a corner case where my code actually performed better than Christians code!
SpoilerIt was one time mind and it was a corner case. Never beat him since and I have stopped trying. What is the line by the Who?
I give my crown to him. How do you think he does it? I don't know. What makes him so good?"
Ben
It's definitely the avatar. A Wizard vs. a Teddy Bear??? What did you expect?
08-23-2019 01:34 PM
@sam67 wrote:
Hi, i wanna to know about local variables implementation. Is local variable effect the speed of program? if yes then what we will use instead of local variables? Any suggestion
Your question is way too vague.
Everything you add to or remove from the code (except maybe free comments and stuff in diagram disable structures ;)) will affect the speed of your program. Local variables have their legitimate place (e.g. to programmatically update or reset the value of a control), but the danger is high that somebody coming from a text based programming background will misuse them as classic "variables". Unless you tell us what you are using them for at the moment we cannot even guess what you should use instead.
Local variables are always tied to a front panel object and thus should not be used as data storage for something that should only exist on the diagram. Controls/indicators should primarily be used to communicate with the user. They keep their own data copy and also maintain a transfer buffer to asynchronously update the visible part in the UI thread. They would at least triple the resource/memory requirement for something that could easily be held in a shift register or wire.
Tell us how you are using local variables and we'll tell you if the use is sound or if there are better alternatives. 😉