LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Local Variable

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  

0 Kudos
Message 1 of 7
(2,405 Views)

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, …

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 7
(2,396 Views)

... and, if we are talking about While loops and For loops, Shift Registers ...

 

Bob "The Wires are the Data" Schor

Message 3 of 7
(2,389 Views)

@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

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 7
(2,342 Views)

@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. 

 

 

Spoiler

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!

 

 

Spoiler

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?"

 

 

 

 

Smiley Happy

 

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

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 5 of 7
(2,339 Views)

@Ben wrote:

 

 

Spoiler

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!

 

 

Spoiler

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?"

 

Ben


 

It's definitely the avatar.  A Wizard vs. a Teddy Bear???  What did you expect?

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
Message 6 of 7
(2,281 Views)

@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. 😉

Message 7 of 7
(2,262 Views)