08-20-2009 09:49 AM
Gerd,
That worked perfectly and it was so much faster.
Thank you!
Chris
08-20-2009 09:59 AM
smercurio_fc,
Thank you for reply.
The vi was written in an older version which is why the Read From SGL File vi was used. Also, Write to SGL FileThe was used in the vi to collect the data and write it to the file. The offset and number of rows controls are a remnant of an older vi which I used as a base for this one Neither are needed and can be removed.
Thank you for the array comments. I will use them in future vi's.
08-20-2009 10:01 AM
Hi Humada,
it was faster because:
- I switched to auto-indexing, LabView is optimized for that case.
- I do the appending of the timestamp in the loop, hence appending to a small 1d array. You did the insertion on the big whole array, blowing from 56MB to 64MB with a lot of datacopying involved. (Not to forget all those coercion dots, which really can hurt on big arrays...)
08-20-2009 11:49 AM
Gerd,
I am new to using Labview, as you could probably guess, and I appreciate your explanation of why your vi was faster. You mentioned that the coercion dots would also slow down the loop and smercurio_fc mentioned that it was a problem on my vi as well but I do not know what you mean by coercion. Could you explain a little further?
Thank you,
Chris
08-20-2009 12:57 PM
Coercion dots appear whenever there's an implicit conversion of one data type to another, like from an integer to a floating point or vice-versa. LabVIEW is telling you that there's a data type change occurring there that it's doing. This can occur if you wire two different datatypes into a function like Add. If you wire an integer and a double, then the output will be a double since it's the larger datatype. The integer will get coerced into a double so the floating point addition can occur. Whenever this occurs with arrays it's almost always bad since arrays can be large, and hence the operation is expensive in terms of memory and time.
There's a chapter in the LabVIEW Help on memory usage. A copy of it can be found here. About halfway down there's a section titled "How to Generate Data of the Right Type" that shows you the impact of coercion on arrays.
08-20-2009 01:58 PM
smercurio_fc
Thank you for the explanation and the link. I will be sure to watch for them from now on.