From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Saturday, Nov 23rd 7:00 PM CST - Sunday, Nov 24th 7:45 AM CST, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-07-2012 05:57 AM
Thanks now only starting to learn those things. Will this be OK?
05-07-2012 06:00 AM
05-07-2012 06:02 AM - edited 05-07-2012 06:07 AM
Hi Anand,
it get's better.
- It would be fine to compare two operations doing the same. As of now you compare your "replace" algorithm with TiTou's "delete" algorithm...
- Updating indicators (like "iteration count") in the tested loops will hurt performance a lot. Don't do that for benchmarking...
- Even now the compiler might be too smart for you. It might "know" your test-array is built from NaNs and might precompile (part of) the loops...
05-07-2012 06:09 AM
05-07-2012 06:10 AM
Looks cool. Learnt a new thing today 🙂
05-07-2012 06:17 AM
@GerdW wrote:
Uf... it's a bit unfair to fill the array with only NaNs... I mean, when I tested my algo I used the kind of data I had, that was arrays between 100k and 2M samples with a max of 10 NaNs for each 100k samples...
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
05-07-2012 06:23 AM
05-07-2012 06:29 AM
That's what I was expecting.
What I'm wandering now is what happens memory-wise. Is LabVIEW smart enough to do Anands loop inplace?
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus
05-07-2012 06:31 AM - edited 05-07-2012 06:36 AM
From looking into the algorithms (and their differences), i would guess that TiTous IS indeed slower than Anands for increasing numbers of NaN's to be replaced.
But i have to point out that with increasing array size, TiTou's will outperform Anands since it reuses memory (works on the original array "in place") whereas Anands create a complete new array.
Norbert
EDIT: Arg, two times misread the code, sorry....
EDIT 2: In order to get proper benchmark results, you have to execute the VI at least two times without unloading it inbetween (and doing other, performance wasting stuff). The first iteration results in incorrect values because of "organization stuff" like allocating memory.
05-07-2012 06:49 AM - edited 05-07-2012 06:53 AM
A comment first on the comparison:
You cannot really do the timing-test that way:
Now, to the suggested solutions:
TiTou's solution for NaN removal trades memory for speed by creating what could be a huge array of booleans, and then potentially wastes all that speed (and additional memory) by resizing every time a NaN is found. If the arrays are small and/or contain very few NaNs the penalty is limited, but if that is not the case it can be severe. In general repeated use of any array resizing function should be avoided/minimized.
I have not spent much time on finding an optimal solution (in fact I'm quite sure this is not the optimal one), but the following code would definitely win a comparison test in cases where the task will in fact involve some work (i.e. large array with at least some NaNs):
As for replacing NaNs with zeroes Anands code is fine, but yes - using the search function instead of comparing the elements one by one is quicker so a better aproach would be like this: