Jump to content

How can I improve while loop speed on windows?


Recommended Posts

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.

  • Thanks 1
Link to comment

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 by smithd
  • Thanks 1
Link to comment
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:

  1. Let it run faster by adjusting the code inside the loop accordingly
  2. Split it into multiple loops to utilize more cores of your CPU
  3. 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 by LogMAN
  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.