06-22-2020 04:27 AM
Hello. Working on the program I noticed that speed of item replace in array substantially depends on array size. How to explain It? The only explain I see is that full array is rewriting in spite of the what part/item of array you replace. Is there any way to overcome this effect?
I have created very simple example to demonstrate that issue. It is in attachments. Example calculates time required to change 10k items in 100k array and time reqired to do the same with 1M array. I have tried "Replace Array Subset" block and "In-place" structure. The result is the same.
I would be pleased for any help.
Solved! Go to Solution.
06-22-2020 04:43 AM - edited 06-22-2020 04:47 AM
Hi Surm,
several problems in your VI:
- coercion dots
- overuse of local variables
- running benchmarking code in parallel
- …
Try this:
Both sequences need <2ms on my laptop.
Have you tried to replace the FOR loop by a single ReplaceArraySubset function?
06-22-2020 06:07 AM
Hi GerdW,
thank you for reply. It is interesting. You have used shift register. It increased the speed of items change very much. I have compared two method. With no use of shift register to rewrite 10k items in 100k array takes 0.5 sec. With shift register it takes <2 ms.
It is not evident for me why shift register is more performance then property node use. So just remember that feature.
06-22-2020 06:15 AM - edited 06-22-2020 06:16 AM
Hi Surm,
@Surm92 wrote:
It is not evident for me why shift register is more performance then property node use.
By using local variables LabVIEW has to create additional buffers and copy the data each time. The larger the buffer, the longer it takes to copy data! (And it is very bad style to (over)use locals where a wire is sufficient…)
On the other hand data in the shift register doesn't need to be copied. See the profiling tools -> "show buffer allocations"!
Your image still shows several coercion dots: they can influence execution speed as well.
06-22-2020 06:43 AM
Now it is clear. Thank you very much for help.
06-22-2020 06:59 AM - edited 06-22-2020 07:00 AM
You can completely remove the local variables here. Again, use wires whenever possible.