I'm working on a data acquisition program and am trying to implement some of the suggestions I've seen on this forum for handling large arrays and displaying them. I think I'll have more questions on this later, but I've run into a surprising effect and wanted to see if you guys could help explain it.
My plan is to keep my data array in the shift register. I will initialize and use replace array subset to reduce memory reallocations. Since I am plotting the array directly, I don't want the initialized data showing up on the plot, so I am initializing the arrays with NaN. My observation is that it takes much longer for a labview plot to update when writing NaN than with a real number of the same representation.
Interestingly, the loop processing the data and sending it to the plot is not slowed down by this effect, but the plot itself updates much more slowly than the loop does. I'm including an example program to illustrate the effect. With it, you initialize an array and the loop continually sends the array to the plot with or without decimation (by a factor of 100). Indicators show the ms/loop iteration and the current iteration count.
As expected, making the initialized array larger slows down the loop and decimation speeds up the loop, but I didn't expect the intialized value to have such an effect. A couple of scenarios to illustrate the point:
1) Set array size to 1,000,000 points and initialize with zero and no decimation. Notice the ms/iteration and how quickly the iteration count seems to update.
2) Now change the initializing element to NaN, and re-initialize. Notice how the ms/iteration is the same, but the iteration counter is clearly updating much more slowly. In both cases, I note that the memory assigned to labview is about the same (although large).
I realize the more elegant solution would be to reduce the size of the array before plotting (something I'm working on), but I am still curious about this effect. It is hard to quantify since labview seems smart enough to keep the loop going even if the front panel is struggling to update, but the effect can be clearly seen.
What do you guys think? Any explanations?