LAVA Good Posted April 16, 2019 Report Share Posted April 16, 2019 I coded in while loop. The loop speed is so slow... How can I improve my while loop speed? And What is the maximum speed in while loop? Quote Link to comment
willsan Posted April 16, 2019 Report Share Posted April 16, 2019 the while loop speed is associated with code and memory of computer, so can you show your source code? Quote Link to comment
LAVA Good Posted April 16, 2019 Author Report Share Posted April 16, 2019 Oh my code is simple. I just want to know how to reduce loop speed anyway thank you for your reply Quote Link to comment
Antoine Chalons Posted April 16, 2019 Report Share Posted April 16, 2019 The being simple doesn't mean it's going to execute fast, I think there is more to optimise in the code inside the loop than anything else. That said, one thing that might help (again depending on what's in the loop) is to change the while loop for a timed loop to which you can give the highest priority. Also if you have some NI Hardware available you could use the clock as the reference for the loop, but that would probably improve jitter more than raw speed. 1 Quote Link to comment
smithd Posted April 16, 2019 Report Share Posted April 16, 2019 (edited) In the compiler doc here (https://www.ni.com/tutorial/11472/en/) theres mention of a yieldIfNeeded block which is inserted into loops which allows for coordination with the rest of the runtime. If you just have the one while loop, you are still having to check against the runtime engine if you should keep running or if you need to pause and let other code run. Its not just a simple jump. tl;dr I dont think there is any way to do this with a regular loop. A timed loop may work. The overhead should be minimal compared to any actual code you wish to run in the loop, and if that isn't true labview is probably not the tool for the job. Edited April 16, 2019 by smithd 1 Quote Link to comment
LogMAN Posted April 16, 2019 Report Share Posted April 16, 2019 (edited) 5 hours ago, LAVA Good said: How can I improve my while loop speed? There are multiple ways actually. Here are a few that come to mind: Let it run faster by adjusting the code inside the loop accordingly Split it into multiple loops to utilize more cores of your CPU Buy a faster computer Note that there is a limit to how many concurrent threads LV supports: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000PARmSAO&l=en-US 5 hours ago, LAVA Good said: And What is the maximum speed in while loop? The maximum speed of a while loop is only limited by the speed of your CPU at 100% load (and of course the way your operating system shares the CPU between processes and threads). That is assuming your loop does nothing, which makes it pretty useless. Of course, if your computer has multiple cores, you can run multiple loops in parallel to make use of them. 4 hours ago, LAVA Good said: Oh my code is simple. I just want to know how to reduce loop speed anyway thank you for your reply This is contradictory to your first statement. I suppose you mean to increase the loop speed, right? If your code is simple, it should be easy to optimize for speed or to run multiple instances concurrently if applicable. Edited April 16, 2019 by LogMAN 1 Quote Link to comment
LAVA Good Posted April 22, 2019 Author Report Share Posted April 22, 2019 Thank you for your kind reply. I totally understand about while loop mechanism. It's helpful for me. Quote Link to comment
shoneill Posted April 23, 2019 Report Share Posted April 23, 2019 Turn off debugging will certianly help. Quote Link to comment
shoneill Posted April 23, 2019 Report Share Posted April 23, 2019 On the other hand: What is "too slow". What should "faster" be? Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.