Arrays: Build array in multiple for loops or replace array elements 
Author Message
 Arrays: Build array in multiple for loops or replace array elements

I need to build a 3D array (200X100X100) or I can programatically
replace array subsets in an existing initialized array of dimensions
200X100X100.

I was wondering if there are any memory advantages to using build
arrays VIs in multiple for loops with shift registers or whether it is
advantageous to replace array elements.



Mon, 24 Oct 2005 00:03:33 GMT  
 Arrays: Build array in multiple for loops or replace array elements
There is a distinct speed advantage to using Replace Array Element as
opposed to using the Build Array function. With the Build Array,
labview has to keep resizing the array buffer. This can add a lot of
extra time for large arrays. This specific subject is discussed in the
LabVIEW Performance and Memory Management pdf document that is part of
the LabVIEW Bookshelf.


Mon, 24 Oct 2005 00:15:30 GMT  
 Arrays: Build array in multiple for loops or replace array elements
This was the standard answer before LV 6i.

LV is pretty good about guessing how much space should be allocated
and will do this ahead of time.

I did not trust this info when I first read it in the release notes
for 6i.

So...
I sat down and wrote a bench mark to compare my "allocate and replace"
vs "for loop with auto-indexing". There used to be (prior to LV 6i) a
big diffence in the performance.

The two method are now virtually identical!

Note:
This test was done using a 1-d array. I did not bench mark
multidimensional arrays.

Ben



Mon, 24 Oct 2005 20:41:15 GMT  
 Arrays: Build array in multiple for loops or replace array elements
I followed Dennis' advice about using replace vs. build array VIs.

For the 200X100X100 array Labview allocates ~25MB of memory vs. 100MB.
So the savings with replace array appears sub substantial.

Thanks for both of your replies.



Mon, 24 Oct 2005 21:00:10 GMT  
 Arrays: Build array in multiple for loops or replace array elements
The other aspect of this question is execution time. And in general
the answer Dennis gave is best from that standpoint as well.

Still it is sometimes valuable to test assumptions. For example, I
found out on a project once that doing something the "wrong" way five
or six time could take a lot less time than doing it the "right" way
five- to six-hundred times.

Mike...



Tue, 25 Oct 2005 12:04:55 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. convert 2d array to 1d array without using shift registers and build array

2. Shifting array element & regex on array element

3. Access Array Elements by Arrays Reference

4. for every element of array find bounds in another array

5. Array and creation of the elements of the array

6. Adjustable array dimensions specified via array element?

7. creation of array elements and write traces on an array

8. selecting array elements with a logical array

9. (typep (make-array 10 :element-type 'bit) '(array bit (10)))

10. Do array element traces affect the whole array?

11. An array as an array element?

12. overhead of tracing arrays vs. array elements

 

 
Powered by phpBB® Forum Software