LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Many arrays vs array of clusters

Highlighted
I have a need to store and retrieve 4-5 parameters of each of about 30 data items.  I would normally use an array of clusters to hold the data.  However, in this instance, I need to be fast as possible - retrieving the parameters for the data items will occur almost constantly in the background.  I got to thinking if it would be any faster to use separate arrays for each parameter and performing five indexing operations.  I know clusters do add some overhead, but how much difference is there between 1 array index followed by a 4-element cluster unbundle vs (much less elegant!) 5 array indexes?
 
Thanks,
Bill F
0 Kudos
Message 1 of 7
(962 Views)
How about using a plain 5x30 2D array?

LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 2 of 7
(956 Views)

Ok, well that would get rid of having 5 different arrays, but you still have to do 5 separate indexing operations right?  So timewise, is it significantly faster than using a cluster?

Bill F

0 Kudos
Message 3 of 7
(952 Views)
I have not compared the difference in runtime between unbundling and indexing an array.
But array indexing is one of the fastes operations.
Guenter
0 Kudos
Message 4 of 7
(949 Views)

OK then, a 5x30 array it shall be.

Thanks,

Bill F

0 Kudos
Message 5 of 7
(931 Views)
A quick experiment suggests the array of clusters may be about 2x faster.  That may be due to my use of Index Array requiring additional buffer allocations, I'm not sure.

0 Kudos
Message 6 of 7
(920 Views)
You are right: The runtime disadvante for the array benchmark should come from the additional buffer allocations. Very interesting benchmark, by the way - my prediction on the runtime would have been different.
I could not sleep in without having modified your benchmark and having added some Replace Array Subset code (and using smaller array dimensions at the same time - my PC isn't that fast). Once it is inserted, the array solution is faster on my PC. (I set the default values of execution time indicators to those on my PC. The execution was done in LV 8.0.1, the VI is saved for 7.1.1)
 
Again, good work. Nice to have seen this.
Best regards, Guenter
0 Kudos
Message 7 of 7
(890 Views)