LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to cure a circular array bottleneck

Solved!
Go to solution

Hi,

 

I'm having a bit of a bottleneck issue using a circular array. What I need is a buffer like structure of doubles that will permit me to access an element at the end and run as efficiently as possible. I originally used a queue which took about 40 seconds to process a txt file I'm using for testing. I changed to a circular array and am now at 12 seconds total. I need to get it faster if I can as this single buffer accounts for about 75% of my runtime and is the single largest bottleneck.

 

Is there any other structure that I could use to keep a fixed size buffer and access the element at the end more efficiently? Am I implementing the array in the most efficient manner? I've attached my VIs and screenshots. "simplefixedbuffer" is the circular array, and "getNextCircularIndex" is the mechanism for updating the pointers to the beginning and end.

 

My assumption that this is the most efficient way to do this is based upon the belief that no copying of the entire array is taking place inside the native labview "Insert Into Array" function since I am enforcing a fixed size for the array. Please correct me if this assumption is wrong or if there is another insertion method I should use to avoid copying.

 

Thanks!

 

simplefixedbuffer.JPG

 

circularindex.JPG

 

Download All
0 Kudos
Message 1 of 7
(2,805 Views)
Solution
Accepted by topic author kgolden

You want replace subset not insert into array. You're also allocating an array of buffer size for every call.

Message 2 of 7
(2,799 Views)

Thanks a bunch! That cut my total runtime in half and that particular VI is not even showing up anywhere near the top consumer anymore. Kudos to you. 

0 Kudos
Message 3 of 7
(2,783 Views)

Feedback nodes make me uncomfortable...

 

This should be very fast...

 

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
Download All
0 Kudos
Message 5 of 7
(2,764 Views)

Opps my examples were for a circular buffer. When he looks the poster wanted a delay.

A delay can be created with a feedback node (assuming the delay amount is known design time constant). In the rare times I use a non one delay I set the display to Z-transform form so it's clearer that it's not normal.

 

0 Kudos
Message 6 of 7
(2,755 Views)

@Matt W - Fascinating.... but I still don't like feedback nodes. Smiley Wink

Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 7 of 7
(2,687 Views)