LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Speed of replace items in array depends on array size.

Solved!
Go to solution

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.

0 Kudos
Message 1 of 6
(1,944 Views)

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?


Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(1,937 Views)

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. 

 

Test.png

 

It is not evident for me why shift register is more performance then property node use. So just remember that feature.

 

0 Kudos
Message 3 of 6
(1,895 Views)
Solution
Accepted by topic author Surm92

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.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(1,888 Views)

Now it is clear. Thank you very much for help. 

0 Kudos
Message 5 of 6
(1,875 Views)

You can completely remove the local variables here.  Again, use wires whenever possible.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 6 of 6
(1,869 Views)