Download G Programming Reference Manual

Transcript
Chapter 26
Performance Issues
The best solution, shown in the following illustration, is to convert the
random number to single precision as it is created, before you create an
array. Doing this avoids the conversion of a large data buffer from one
data type to another.
Avoid Constantly Resizing Data
If the size of an output is different from the size of an input, the output
does not reuse the input data buffer. This is the case for functions such
as Build Array, String Concatenate, and Array Subset which increase or
decrease the size of an array or string. When working with arrays and
strings, try to avoid constantly using these functions, because your
program uses more data memory, and executes more slowly because it
is constantly copying data.
Example 1: Building Arrays
As an example, consider the following diagram which is used to create
an array of data. This diagram creates an array in a loop by constantly
calling Build Array to concatenate a new element. The input array is not
reused by Build Array. Instead, the VI continually resizes the output
buffer to make room for the new array, and copies data from the old
array to the new array. The resulting execution speed is very slow,
especially if the loop is executed many times.
G Programming Reference Manual
26-24
© National Instruments Corporation