LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

append rows - which method is faster

Solved!
Go to solution
The results are not really that suprising. With method 3 you incur the time hit from having to allocate the array. Even by taking it out, it's not going to be faster in this case because you have to iterate over the rows. The other 2 method do not have this "impediment", so that's why they're faster.
0 Kudos
Message 11 of 15
(986 Views)

You can answer such questions yourself with a timing tool:

 

What Time Is It 

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

0 Kudos
Message 12 of 15
(980 Views)
Well, I can time the operation. My question now is if there is more efficient way of using the memory preallocation and then replacing the elements (method3) as ppl suggested before.
LV 2011, Win7
0 Kudos
Message 13 of 15
(977 Views)

Not for your specific case. And that's because Replace Array Subset doesn't take a 2D array as the new element/subarray if the input array is 2D. This means that you need to replace by rows/columns as your method 3 does. In each of your methods the outer for-loop is simply running the same method N times. When you remove this we see that we're left with basically a single operation for the Insert Array method, a few operations for the Build Array method, but a whole loop for the Replace Array Subset method (which has a Build Array inside the loop to boot). This last method will take longer in this specific case.

 

Preallocation and use of Replace Array Subset is useful as an alternative to using Build Array inside a loop to create an array. This does not mean that it's the most efficient method in all cases. As always, the task to be accomplished dictates which method is the most efficient method.

Message 14 of 15
(959 Views)
thanks smercurio. I just wanted to be sure that I didn't overlook something and there is no better way. Thanks
LV 2011, Win7
0 Kudos
Message 15 of 15
(950 Views)