02-16-2024 09:09 AM - edited 02-16-2024 09:21 AM
Going back to the original problem that the UI thread is dramatically overloaded, an easy test would be to set the graph to "synchronous display", forcing a full redraw before the code is allowed to continue.
Now the lower loop time is half a second!!!
This tells you that while the graph update is asynchronous, once it decides to redraw, the UI thread gets highly taxed for a significant time duration.
I still don't quite understand why retrieving a static reference needs to UI thread and is not constant folded.
For example why wouldn't LabVIEW transparently just do the following behind the scene, greatly speeding up the upper loop?
The problem is actually the timing sequence which forces the loop to no longer be constant folded. If we get rid of the time measurements, the upper loop is again very fast and constant folded. (Setting the timeout to zero, gives a loop time in the low microseconds while in the earlier case it was tens of seconds).
A clear case where the act of measuring changes the outcome!
If we eliminate the constant folding artificially, the loop again gets slow. It is not clear to me why the compiler does not treat the static references as loop invariant code. I think it should....
If we eliminate the auto-indexing on the refs (i.e. make the tunnel "last value" and the array 1D), the loop speeds up 32 times because the compiler is smart enough to only retrieve the references on the last iteration:
02-21-2024 07:07 AM
thanks for sharing...