10-17-2014 12:35 PM - edited 10-17-2014 12:36 PM
@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.
Unofficial Forum Rules and Guidelines
Get going with G! - LabVIEW Wiki.
16 Part Blog on Automotive CAN bus. - Hooovahh - LabVIEW Overlord
10-17-2014 12:44 PM
The main problem is that the "#" format is expensive. If you would substitute e.g. %.06f, the difference is much smaller.