From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Performance/Programming Question ?

Hello all.

I am wondering about the merits of using global/local variables or
shift registers. I would think that the global/local variables would
give better performance than using shift registers to send info back.
Does anyone have some information on the pro's and con's of each
method? Does one give you a faster program, take up less memory,
result in fewer problems?

Thanks for sharing anything you might have on the subject.

Regards,

Steve Drake
0 Kudos
Message 1 of 4
(2,525 Views)
Steve Drake wrote:

> Hello all.
>
> I am wondering about the merits of using global/local variables or
> shift registers. I would think that the global/local variables would
> give better performance than using shift registers to send info back.
> Does anyone have some information on the pro's and con's of each
> method? Does one give you a faster program, take up less memory,
> result in fewer problems?
>
> Thanks for sharing anything you might have on the subject.
>
> Regards,
>
> Steve Drake

Steve,
As with most things, it all depends on what you want to do.
Here are some pros / cons from each item

Memory (biggest to smallest ) : Global, local, shift register (SR)
Disk space (big to little): Global, local , SR
Execution (long to short): Local, global, SR (l
ocal is longer because of
screen updates)
Test case: 10000 interations of a for loop, read , +1, write. Used profiler
to get information over 5 runs.

Each has a place:
Global for VI to VI data exchange
Local to use one object as control and indicator, can help clean up diagram
Shift register is only useful (obviously) in while and for loops.

Globals and locals suffer from race conditions, you have to pay a lot of
attention
to who is writing and who is reading and WHEN.

I hope this clears up the mystery.
Kevin Kent
0 Kudos
Message 2 of 4
(2,525 Views)
In article
,
Steve Drake wrote:
> Hello all.
>
> I am wondering about the merits of using
global/local variables or
> shift registers. I would think that the
global/local variables would
> give better performance than using shift
registers to send info back.
> Does anyone have some information on the pro's
and con's of each
> method? Does one give you a faster program,
take up less memory,
> result in fewer problems?
>
> Thanks for sharing anything you might have on
the subject.
>
> Regards,
>
> Steve Drake
>
We use shift registers to hold program
information. Although LabVIEW handles Global and
local variables quite elegantly they are
generally thought of as Software Engineering No-
No
. Globals are an indication of common coupling
and this is a bad thing. As far as I can remember
Locals make a copy of each instance in memory.
Although nowadays this is not a huge problem.
My advice to make component objects that contain
their own data in shift registers and access that
data by enum commands.

Steve Watts SSDC



Sent via Deja.com http://www.deja.com/
Before you buy.
0 Kudos
Message 3 of 4
(2,525 Views)
Go with shif registers. Avoid globals, you can pass data to other VI by
using VI references invoke node property.
In general use state machine and then shift registers will come naturally.

"Steve Drake" wrote in message
news:qdi2esgud443gkjdss6p7bbam72at5bsi7@4ax.com...
> Hello all.
>
> I am wondering about the merits of using global/local variables or
> shift registers. I would think that the global/local variables would
> give better performance than using shift registers to send info back.
> Does anyone have some information on the pro's and con's of each
> method? Does one give you a faster program, take up less memory,
> result in fewer problems?
>
> Thanks for sharing anything you might have on the subject.
>
> Regards,
>
> Steve Dr
ake




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
0 Kudos
Message 4 of 4
(2,525 Views)