NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Show a delay be put in a While Loop to avoid clogging CPU as per Delay 0 in LabVIEW

Hi,

 

From LabVIEW Wiki

"Execution speed

While Loops execute as fast as possible and therefore can be a cause for high CPU load. For this reason While Loops should be throttled by using the Wait (ms) function with a delay time that is appropriate for the task."

 

It is common practice to place a fixed Delay or a 0 delay in While Loops or For Loops in LabVIEW to avoid clogging up the CPU. What is the situation in TestStand, for example 

 

Do While (StationGlobals.ChamberInterval == 0)
End

 

 

Danny Thomson AshVire Ltd
0 Kudos
Message 1 of 4
(1,134 Views)

@danny_t wrote:

It is common practice to place a fixed Delay or a 0 delay in While Loops or For Loops in LabVIEW to avoid clogging up the CPU. What is the situation in TestStand, for example 

 


(Not a Teststand user, so I cannot answer your core question)

 

As a general comments, a fixed delay should be in polling loops (toplevel, UI, etc.) that run forever and can be omitted if there are waiting nodes (event structure, dequeue, etc.). A 0ms wait will force a thread switch and potentially more overhead, especially if nothing else important wants a slice of the pie. Non-interactive while loops that are lightweight and complete quickly should NOT have a 0ms wait so they can efficiently complete (for example a Newton method).

0 Kudos
Message 2 of 4
(1,124 Views)

Throttling down polling loops with a delay is a good design practice in any programming language. 

So I would use this in TestStand also.

 

 

0 Kudos
Message 3 of 4
(1,088 Views)

I use Wait steps in while loops in TestStand quite frequently. There are instances where I command an instrument to do an acquisition or some other process that can take a couple seconds to complete (Spectrum Analyzer, for instance). Typically when interacting with those instruments, you initiate the acquisition, then you poll the instrument for its measurement/acquisition status to know when the instrument has completed its task.

 

I don't want to spam the instrument with status requests, so inside my while loop where I send the status request command over and over again until it returns that the action is complete, I use a Wait step.

 

Like Altenbach and Oli_Wachno already mentioned, it's good practice anywhere to limit while loops from free running as fast as possible, but there are also instances where you want a process to run quickly - it's all up to what your application/function needs.

Jorr-El
Systems Engineer
Testeract: Automated Test Specialists
0 Kudos
Message 4 of 4
(1,076 Views)