05-13-2014 07:12 PM
@matteci wrote:
I'm of the impression that using 'type cast' to get the numeric data out of the cluster is making a new memory buffer every time it's run, and is similar to using 'build array'.
Let's clarify one thing: using build array in a loop is not necessarily bad. The problem is using build array in a loop where the output grows on each iteration because that requires allocating new memory each time, then copying the entire array into the new location. If the array size stays constant, LabVIEW can precompute the space required and there's no penalty.
As for the use of Type Cast - I don't believe it's allocating a new buffer every time it runs. It is, unfortunately, making an extra copy of all the data (see the help - Type Cast is effectively a flatten to string/unflatten from string), but it should do so in the same buffer each time, since the size doesn't change. The amount of time required for that copy is proportional to the size of the cluster, and is unlikely to be significant unless your cluster is huge.
My recommendation is stick with the simple typecast unless you find that it's causing problems. If you start to suspect that it's the problem, benchmark it against other approaches. I've used typecast in the past in high-performance real-time applications and haven't found it to be a problem.
05-13-2014 07:18 PM
Hah! I kind of had the feeling that I was doing all sorts of unnecessary exercise. Thanks for the clarification. THANKS!