LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Floating point array to string conversion

Solved!
Go to solution

@Jimmy.chretien wrote:

Well well well OriolesFan... I benchmarked the three solutions including the one with spreadsheet proposed by P@Anand and the Loop version is arround 10X slower than the 6 fix decimals, the spreadsheet one is 2X FASTER than the loop version which is interesting when your code requires some optimization.


Yeah I don't know where you got these numbers from they I'd suspect your timing test is flawed.  Attached is a version that shows the 3 methods.  Creating 100000 random doubles, then converting using the single function limiting to 6 decimal places takes 0.03 seconds.  While each of the other other two methods take roughly the same time at about 0.48 seconds.

 

This is with debugging, and automatic error handling off.  This is also using semi-random numbers because the compiler will optimize things out with constants.  This is also not updating the UI until after at timers have been read because UI elements are updated asynchronously.

 

EDIT:  Tested in Windows 7 x64, LabVIEW 2011 SP1 32-bit edition.

Message 11 of 12
(678 Views)

The main problem is that the "#" format is expensive. If you would substitute e.g. %.06f, the difference is much smaller.

0 Kudos
Message 12 of 12
(670 Views)