ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increasing code speed

I have my own issues with code speed. Some techniques that can help:

1. Update analog and digital inputs / outputs only on a change-of-state, if possible.

2. And / or gate the inputs / outputs with as slow of a RTC (Real-Time-Clock) as will keep the process functioning.

3. If you have to process huge arrays of data at high-speed and at a repetitive high rate, a standard pc or even some low-end workstations may not have the raw horsepower required.

I also have a question pertaining to "tweeking" for speed.

What kind of penalty (in CPU cycles) is exacted for using a global variable as opposed to a local variable?

I design, build and program our in-house test equipment to test the 3-phase surge protection devices we sell.

Some of them are elaborate test sequencers that supply constant-current in steps of 100uA to 100mA and 24vdc to 3kvdc.

This kind of equipment has an lengthy init / POST sequence and needs to run auto-calibration and auto-diagnostic routines in the background when the user is not testing a product. So I build hybrid task managers of 4D I64 arrays that allow for both preemptive and some cooperative multi-tasking. The global variables are easy to access from anywhere with special reset/init/read/write/edit/update vi's).

The question becomes: Does using a global variable(4D I64) as a task registry have a serious code speed penalty over the same size array made as a local variable? As a local variable it requires a lot of links and handles to access and edit its content. Its dificult to tell if  the extra address translation required by using global variables is more of a penalty than having lots of handles and array handling vi's to work with large local variables.

NOTE: Only a single "book" and "page" of the task registry is active at a time. The task mgr only scans the contents of 1 page.

0 Kudos
Message 11 of 12
(546 Views)
0 Kudos
Message 12 of 12
(509 Views)