05-31-2010 02:33 PM
Hi Guys
I'm looking for a bit of performance optimization..
I'm developing a noise measurement application using LV8.6 and Win Xp /Win 7.
To put it very simple I have a loop that samples, and a loop that does the math. data is shipped in a queue, producer / consumer style.
So far so good.. Question is - is there a specific and more optimized way to declare this queue?
I was wondering if declaring the queue with an initialized array element of a fixed size (the number of samples pr. read from the sound card will be known at runtime) would produce a queue that would be less heavy on dynamic allocation of memory compared to a queue obtained using a simple control no values.
I've attached a screen dump to maybe make the question more obvious..
I've been thru the "clear as mud" thread, as recommended in other threads that covers this topic - but i gets very high tech, and I kind of lost my way in it.. So looking for a more simple "you should use solution #x, because..."
Thank you in advance.
Solved! Go to Solution.
05-31-2010 02:55 PM
you should use solution # 2 because Initializing an array first and then replacing its elements allocates all the necessary memory at once as opposed to rearranging memory as the array grows in size.
05-31-2010 03:09 PM
H Sh wrote:you should use solution # 2 because Initializing an array first and then replacing its elements allocates all the necessary memory at once as opposed to rearranging memory as the array grows in size.
What does your answer have to do with a queue?
Using option 2 will not do a thing about creating a queue with a fixed number of elements. With either, you start with an empty queue. If you used an empty array constant with option 1, then that would require less memory in the VI itself. If you wanted to set the queue size, wire something to that input.
05-31-2010 11:18 PM
Oh yes my mistake.. In queue there is no replacement of elements as it will enqueue the elements at the end.. so no need to allocate the size in starting infact of no use and will unneccessary holds some memory..
so solution #1 is better option..
06-03-2010 03:40 PM
03-26-2013 03:06 PM
Wire into the queue element data type input a build array function with 2 elements (say 0 and 1) also works.
03-26-2013 03:20 PM
@jcannon wrote:
Wire into the queue element data type input a build array function with 2 elements (say 0 and 1) also works.
(Why so complicated? It would work equally well with a build array function with a single input, or even with an empty array diagram constant.)
Any array of the desired datatype will work, no matter how you create it. Only the type is important, the data is ignored.
03-26-2013 03:27 PM - edited 03-26-2013 03:31 PM
I believe (but am not sure) RT FIFOs will allocate this memory for you ahead of time. But, remember they are not deterministic on windows. You need to wire an array constant of the correct size into the FIFO read function also to avoid memory allocation, which is easy to overlook. It's worth looking into, if nothing else, assuming you have RT functions available. WIth this method, the queue size needs to be set, and you run the risk of overflowing and losing elements if not handled correctly.
Just throwing other options out there.