Showing results for 
Search instead for 
Did you mean: 

Time Measurement in a While-Loop

Go to solution

Greetings gentleman;


I am a little bit new at Labview, and though i searched for an answer without posting, i was not able to find one.


So here is my question, i would like to know how can i measure time of a loop sequence, in other words, how much time does my VI take to execute the whole main loop ?.


A little explanation, the attached VI tries to be a Markov Chain, it takes some values in the first case structure depending of the previus loop, then, if the values are correct, it goes to the next step and so on. It is quite simple, yet, my issue lies with the time measurement. Since this is a probability "distribution" it could take infinite time to execute one single loop if it does not meet the requierements, but is programmed to meet them so an average timing should work.


So, if you look at the While loop, the big one, that i would like to measure how much time does it take to do one round.


Thanks for the help, i would be glad to read some ideas on how to measure that.


Kind regards,




0 Kudos
Message 1 of 5
Accepted by topic author Stgo

You can find a few examples in the NI Example Finder by searching for 'speed test' or 'benchmark'.


Essentially, you create a flat sequence structure inside your while loop. In the first frame, you measure the current tick count. In the middle frame, you run your code. In the final frame, you measure the tick count again, and subtract the first count from this. This gives you the execution time to run the code.


You can see a community page on it here.


There's a high resolution tick/time count VI hanging around somewhere which is excellent for benchmarking and improving efficiency, used in place of the Tick Count (ms) primitive.


Edit - remembered where it was 🙂

Message 2 of 5

Hi Stgo,


I don't really like the way it's programmed.

You can use a for-loop instead of a SSS, since the code is the same.

Anyway here it is with timing.

Takes 3 to 15 seconds orso.




UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 3 of 5

Thank you very much for your precise answer, i have learned to do it and it is now understood.


Now, KoenR94, i see you made a suggestion with the for-loop. Would you like to please explain it, i also thought it was better with for loop but i got confused and i just went the simple way i thought of doing it.

The problem with it is that there are 5 differents events, in the programation it is only one repeating itself, i know, but the real scenario has 5 with different probability, should have explained that sorry.


Anyway, any suggestions are well received.




kind regards,




0 Kudos
Message 4 of 5

Hello Stgo,


I changed it to a for-loop, they still have the same event.

A nicer way is to lose the single indicators an make two arrays instead, this way you will lose the index arrays.

Anyway getting different events into the for-loop is pretty easy.

Create another case structure around the True/False structure, then wire the case selector to the I (iteration indicator) of the for-loop.

Hope I explained enough, if you still have questions don't bother to ask.




UnCertified LabVIEW Student
Mistakes are for learning, that's why suggestions are always welcome!
0 Kudos
Message 5 of 5