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

@Karan_jasani wrote:

Hi,

Please find attached VI where input array is having default values.

The output is correct but takes around 5 minutes.


2.5 minutes for me.

 

I'm looking forward to see how much Altenbach reduces it.

0 Kudos
Message 11 of 26
(1,763 Views)

@RavensFan wrote:

@Karan_jasani wrote:

Hi,

Please find attached VI where input array is having default values.

The output is correct but takes around 5 minutes.


2.5 minutes for me.

 

I'm looking forward to see how much Altenbach reduces it.


I'm betting two primitives and an auto-indexed FOR loop.  😉

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 12 of 26
(1,760 Views)

@RavensFan wrote:

2.5 minutes for me.

 

I'm looking forward to see how much Altenbach reduces it.


I got it down to 284.9ms...


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
Message 13 of 26
(1,759 Views)

@crossrulz wrote:
I got it down to 284.9ms...

 


 

Mine was pretty similar but I have the gut feeling that it can be optimized further. 😉

0 Kudos
Message 14 of 26
(1,731 Views)

@altenbach wrote:

@crossrulz wrote:
I got it down to 284.9ms...

 


 

Mine was pretty similar but I have the gut feeling that it can be optimized further. 😉


Yep, I've been playing some more.  Preallocating the array and not reshaping seems to help quite a bit.  My Profile Performance and Memory is showing an average of 103.4ms.  Though, this is starting to look a little messy.


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 15 of 26
(1,724 Views)
Solution
Accepted by Karan_jasani

Here's my version. I am on an old laptop. Will test on a more powerful machine later.

 

altenbach_0-1600802557225.png

 

It would be curious if pre-allocating the output array would make any difference. The compiler should be smart enough to figure out the final size. 😉

(And yes, we only need to mask the lower trace, of course. Not shown)

 

Message 16 of 26
(1,728 Views)

(Edited: network problems on my side, couldn't upload images…)

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 17 of 26
(1,722 Views)
Solution
Accepted by Karan_jasani

My approach:

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Download All
0 Kudos
Message 18 of 26
(1,716 Views)
Solution
Accepted by Karan_jasani

Another version (~33ms)....

 

 

altenbach_0-1600803427017.png

 

Parallelization helps slightly, bringing it down to ~22ms. Probably not worth the extra overhead:

 

altenbach_1-1600803516550.png

 

 

0 Kudos
Message 19 of 26
(1,700 Views)

Loopless:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 20 of 26
(1,700 Views)