04-21-2022 02:17 AM
I was trying some tests to see is a while loop can be good to be used in a vi where the time is a really important matter. So I have implemented this simple code to see the duration of iteration of a while loop. Surfing in the net I have already found that because of windows is not a true real time OS, meaning that the priority of the operation can be changed during its execution, the time that each loop takes can greatly change. So recorded in an array all the values of the while loop. Except for the first iteration, which took a time of the order of milliseconds, the others are in order of 10^(-6). I can’t understand way there is such a difference.
Thank you for the help!
Solved! Go to Solution.
04-21-2022 02:45 AM
Do you get the same result if you run it again a couple of times? A VI compiles before running if it's been changed, so i often see a small 'hiccup' the first time, but not on subsequent runs. Otherwise, a loop requires some setup and memory access so that the 1st loop would be slightly longer is no surprise, but not several millisecs.
04-21-2022 04:34 AM
Sorry I have not mentioned that fact: if you have just opened the vi for the first time then the first loop is around 7 ms (but can be also higher), then if you run the vi other times, the first loop duration decreases (0.3-0.2 ms). The same happen if you wait some time (let's say about 15s) between two consequent runs.
I have also thought that the cause could be related to the fact that at the very first iteration the shift register brings back a zero value, and it is possible to see that by highlighting the execution, but then I don’t understand why consequents runs reduce this time, since the vi is still loaded in memory and it is always the first loop.
I hope to have been clear enough! Thank you for the helpI
04-21-2022 04:39 AM
I don’t understand why consequents runs reduce this time, since the vi is still loaded in memory and it is always the first loop.
You are using an uninitialized shift register!