Justin Goeres wrote:
> I have a While loop that runs more-or-less forever, and contained within it
> is a Sequence which runs on every iteration. I have a question about the
> CPU overhead involved in the loop which I will illustrate with an example.
>
> Say there are 4 frames in the Sequence. In frame 1, I write a value to a
> global. In frame 3, I want to use the value from that global. In terms of
> CPU cost, is it more efficient (i.e. quicker) to actually READ from the
> global in frame 3, or to wire a Sequence Local going forward from frame 1?
> There are no race conditions or other dependencies to worry about in this
> case, just wondering about the overhead.
>
> Thanks!
>
> Justin Goeres
> Project Engineer
> Indio Systems, Inc.
> Pleasanton, CA
Justi
n,
I would encourage you to read ch 28 of the G Programming Reference Manual.
This describes some of the issues that you are asking about.
I would also suggest that you not use sequences, you can get the same
fucntionality
using data flow and SubVIs and your code will be much easier to read and
maintain.
I would not use globals if I could find another way to do the job. A global
will
make a copy of itself increasing mem usage and CPU time. They are also
difficult to
use if you have race conditions.
A sequence local is even less desirable. They are hard to follow and if you
have
very many they obscure the intent of the design beyond recognition. I once had
to
debug some code that had 15-20 sequence locals of different types. After a
couple
of days I gave up and redesigned the whole thing in less than a day.
Kevin Kent