08-09-2016 02:32 PM - edited 08-09-2016 02:43 PM
When on Line 0 appears 0 (we detecting indexes) then on line 3 we must subset array starting with every index (length of indexed array = 32). In VI if we increase # repeats, time of execution VI is increasing too. For example, if # repeats=5, time of execution is too low. But if # repeats=40, time of execution is very very high. How this VI can be optimized (decreasing time of execution VI, especially when # repeats>20)?
08-09-2016 03:54 PM
The Append Digital Samples function is doing a Build Array operation. Since the array is of considerable size, building it within the For loop makes repeated calls to the memory manager and takes extra time. Since you are repeating data, the end size of the array is known. If you preallocate a blank array of that size and then replace rows it can all happen within the same space in memory and run faster. I tried it using the indexing output on the For loop, but it ended up being slower.
The While loop can be optimized as well, but it looks like you intend to do more than just count zero indexes.
Here's what I did.
08-10-2016 02:01 AM
Please resave in 2011 version.
08-10-2016 12:54 PM
08-11-2016 12:34 AM
Is it possible while loop to optimize?
08-11-2016 09:08 AM
It is possible, but there appears to be unused code in the While loop. It is not clear if the lower shift register needs to do anything. Without understanding the whole requirement, it is difficult to suggest optimizations. A typical technique is to avoid While loops if there is any way to know the maximum number of iterations in advance. For loops are much faster because there doesn't need to be a decision made each iteration, and memory management is easier for the compiler.
08-12-2016 01:23 AM
@Photon_Dan wrote:Without understanding the whole requirement, it is difficult to suggest optimizations.
In this VI when on Line 0 appears 0 then on line 3 we must subset array (length of indexed array = 32).
08-12-2016 04:24 PM - edited 08-12-2016 04:24 PM
08-13-2016 05:17 AM
@Photon_Dan wrote:I managed to get the execution speed on my PC with 40 repeats down from about 1.5 seconds on the original VI to about 105 msec.
Now, how about some Kudos?
It's OK but you define Indexes (when 0) wrong. As we can see from Graph on Line 0 indexes when 0 are 0, 51, 102 and so on.
08-13-2016 05:41 PM - edited 08-13-2016 05:42 PM