LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

In-place vs auto-indexing vs array subset

Solved!
Go to solution

Hi!

 

I'm trying to understand two things: The exact purpose of the in-place element structure (I mean I can read the help context, but it says "in some cases" --> which ones?) and what difference does it make in a very specific case like the example below:

At program startup, I'm initializing some arrays (and obtaining clusters of queues and other stuff) and these arrays/clusters will change over time through development and I don't really want to have to change re-code my initialization process, so I'm trying to use FOR loops as much as possible; And basically I'm wondering if these 3 options are somehow performing/acting differently.

(This is just an example, thus the select case to show that some elements will never change (sometimes not be an array etc.)

Array indexing.png

 

Thank you in advance for your help 🙂

Vinny

0 Kudos
Message 1 of 5
(853 Views)

Your two top loops will result in a 8 element array each, the third one will result in a 6 element array.

The memory management in LV is generally very good, so in this case the top two loops will probably be identical after compilation.

An example where i've benefitted much from a IPS-solution was when i had an array of clusters (a few hundred) which included some semi large arrays (~100k elements). Indexing out data was surprisingly heavy (due to data copy). Using a IPS it only copied the data i needed which made a big difference.

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 5
(845 Views)

@Yamaeda wrote:

Your two top loops will result in a 8 element array each, the third one will result in a 6 element array.

 


Hmmm I'm not following you ... My array is made of 6 elements, so array size will be 6, so 6 iterations .... No?

 


@Yamaeda wrote:

An example where i've benefitted much from a IPS-solution was when i had an array of clusters (a few hundred) which included some semi large arrays (~100k elements). Indexing out data was surprisingly heavy (due to data copy). Using a IPS it only copied the data i needed which made a big difference.


Ahhh I see, ok I'm not very familiar with memory management (I didn't know that indexing was copying the whole array), I know so Dos and Don'ts, but that's about it for now. 

I'm not dealing with that massive arrays of data for now, so I guess it won't be a big issue for me for now, but good to know for later, thanks!

 

Vinny

0 Kudos
Message 3 of 5
(832 Views)
Solution
Accepted by topic author VinnyAstro

All three versions are basically identical once the compiler optimizations has digested and processed the code. All seem to have the same number of allocation dots.

 

Using the IPE is pointless, because you have no interest in the existing element. It is useful if you want to e.g. add the new element to the existing element.

 

Option 1 and 2 will guarantee that the output is of the same size as the input, even if N is less than the size. In that case, only the first N element will be replaced. If N is larger than the array size, no additional elements can be added. Option 3 will always give you 6 new elements, so it depends what you want.

 

There are of course optimizations outside your focus. For example the unbundling/rebundling could be done with an IPE.

 

altenbach_0-1646845761790.png

 

Unless these data structures are gigantic, use the version with the simplest, most readable and maintainable code.

 

Message 4 of 5
(821 Views)

Thanks for the details Christian, much appreciated.

I'll go with the simplest as my structures are very simple and human readable.

 

 

0 Kudos
Message 5 of 5
(771 Views)