10-03-2023 12:20 PM
Hi,
From LabVIEW Wiki
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
10-03-2023 12:53 PM - edited 10-03-2023 12:53 PM
@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).
10-04-2023 12:21 AM
Throttling down polling loops with a delay is a good design practice in any programming language.
So I would use this in TestStand also.
10-04-2023 08:10 AM
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.