LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Speed Optimization

Solved!
Go to solution

When using shift registers you keep your data in the big 2D array. Replacing single elements is done in place (no memory allocated).

When using auto-indexing the 2D array is basically split into rows and then re-assembled. The replace on the single row is also done in place, but splitting and reassembling the big array is inefficent I think.

 

What surprises me is if you display memory allocations it looks the same for both methods.

0 Kudos
Message 11 of 19
(775 Views)

This example seems to be a bit faster.

 

Your re-sizing can't be done in-place so it's best to simply accept the one data copy and minimise other copies on the same data set.

 

Shane.

Message 12 of 19
(772 Views)

Now you need a copy of a portion of your data.

An alternative to Shane's solution is to rotate the array.

See attachment.

 

From the point of data handling it would be easier and faster if you would split the 2D array in 4 1D arrays. The code will be less scalable, but if the size is fixed (4) then it might be worth it. In this case you always operate on 1D arrays and can do everything in place.

 

Daniel

 

0 Kudos
Message 13 of 19
(767 Views)

After some look around, I just found a link which gives logical reasoning for Shift Registers being faster than Loop Tunnels.

 

http://udc.adicenter.com.cn/download/tutorial.pdf 

 Page 4 and 5 gives the reasoning to the working methods of SR and LT.

 

Ritesh 

0 Kudos
Message 14 of 19
(765 Views)

Hi daniel,

i just ran ur code and found it a bit slower than the one suggested  by Intaris.

While ur code takes about 11-12 ms on my machine, Intaris code took 8-9 ms to complete the operation.

 

 

 

Ritesh 

0 Kudos
Message 15 of 19
(763 Views)

Have you checked the funcitonality?

 

I put it together rather quickly so it may not be doing what you require of it.....

 

Shane.

0 Kudos
Message 16 of 19
(757 Views)

Intaris wrote:

Have you checked the funcitonality?


Yes, its doing exactly the same thing.
But i didnt understand 1 thing in ur code. u r using Build array function the for loop. and as per my understanding, build array function always makes another copy of the output array. 
now i was just keeping an eye on the memory using memory profile and noticed that it took same amount of memory if i ran the loop for 100 or 200 times. 
 
 
Ritesh 

 

0 Kudos
Message 17 of 19
(753 Views)

The array (60000 entires) is being copied ANYWAY.  I'm just stcking another 200 entries ont he end of it before truncating again.

 

The only memory difference is the 200 entries intotal.  It doesn't accumulate per loop, it's released after each loop iteration.

 

Shane.

Message 18 of 19
(743 Views)

Intaris wrote:

The only memory difference is the 200 entries intotal.  It doesn't accumulate per loop, it's released after each loop iteration.


Ok. I didn't know that LV releases the memory occupied by Build array function after the loop is terminated.

Just had the idea that it keeps accumulating it.

Thanks for the Information.:smileyhappy:

 

 

Ritesh

0 Kudos
Message 19 of 19
(732 Views)