LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

optimizing trending code for speed

Any suggestions on how to speed up my code? Get rid of the express VI etc... I'm reading a TDMS file that has about 6000 blocks of data, 32 channels, and each block is 3.2s and acquiring 2560 samples/sec.  So, that is 2560x3.2x32x6000 data points to read through, which equals 1.57286*E9 data points.  Pretty dang big...  I'm reading through all of the points and picking out the max +peak or -peak and trending it, or doing spectral band-pass peak trending.  Most software writes a separate trend file as it is writing the data.  I may do that, but right now I'm just looking at optimizing it in my "Read" .exe.

Download All
0 Kudos
Message 1 of 5
(2,519 Views)

First thing would be to clean up your code, then get rid of the unnecessary indicators (use probes when debugging). Get rid of the express VI.

 

 

Rodéric L
Certified LabVIEW Architect
0 Kudos
Message 2 of 5
(2,516 Views)

You are also building arrays in the loops.  This may cause memory re-allocations which can slow things down substantially.  The complier can optimize some allocations in for loops, but I am not sure it can figure out what is required for your needs.

 

The better way is to initialize the arrays outside the loops, pass the array from one iteratio to the next with shift registers, and use Replace Array Subset inside the loop.

 

Since you end up with arrays of DBL, it may be faster to just use the FFT VIs rather than deal with the Power Spectrum VIs you chose.

 

Lynn

0 Kudos
Message 3 of 5
(2,507 Views)

I just did a quick test, and the automatic array builder is ALOT faster than the array constant, shift register ==> build array. The Build array is ofc needed if you dont always add data to the array, but most (all?) of your array builds always add items.

/Y

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

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

If you're really looking for performance, you can specify a array size that you know you'll never go over. Then just keep track of the number of elements in the array with another data line. This will eliminate the need to reallocate memory any time you add elements. You would of course need to track the number of elements added to the array but its easier to add 1 to something than to asking the OS for more memory. 

 

Its not the most convenient but if its possible might as well.

Kyle Hartley
Senior Embedded Software Engineer

0 Kudos
Message 5 of 5
(2,463 Views)