From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

For loop is taking too muc time to execute

Solved!
Go to solution

@GerdW wrote:

Loopless:

 


Have you counted the allocation dots? Probably significantly more memory overhead with all these seperate intermediary arrays (2D, 1D). Not sure if a few ms are worth it...

0 Kudos
Message 21 of 26
(1,175 Views)

Hi Christian,

 

that's the usual trade-off: time vs. memory consumption…

(I wondered it's even faster when allocating more array wires in between.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 22 of 26
(1,168 Views)
Solution
Accepted by Karan_jasani

Curiously, interlacing is faster than my typecasting (~19ms , or about 8ms when the loop is parallelized).

 

altenbach_0-1600804973434.png

 

 

altenbach_0-1600805353831.png

 

 

I am sure we can squeeze a little bit more out of it, but going from 5 minutes to 10ms is quite good, IMHO ;))

 

The first estimate of getting 1000x improvement was low. We got about 30000x! 😮

 

0 Kudos
Message 23 of 26
(1,160 Views)
Solution
Accepted by Karan_jasani

Hi,

 

not getting so much faster, but there also is a DecimateArray for each InterleaveArray:

Atleast it fits the postage stamp… 😄

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 24 of 26
(1,152 Views)
Solution
Accepted by Karan_jasani

@crossrulz wrote:

Preallocating the array and not reshaping seems to help quite a bit. 

It surprised me that the concatenating tunnel is about 20x slower, even though the compiler could probably figure exactly what to do based on the build array with two scalars inside the loop.

 

Here's what I probably would do in the end:

 

altenbach_0-1600806388224.png

 

0 Kudos
Message 25 of 26
(1,145 Views)
Solution
Accepted by Karan_jasani

@GerdW wrote:

A tleast it fits the postage stamp… 😄


No kidding 😄

 

altenbach_0-1600807442449.png

 

Message 26 of 26
(1,133 Views)