05-11-2021 03:54 PM
More like 10 seconds. Try and wire the index to a boolean comparison and see what happens.
05-11-2021 04:06 PM - edited 05-11-2021 04:08 PM
I am searching large Array for a match in the generated array, it's that simple. This doesn't work either. I have isolated the cause. If you wire the index to try and get the value, it takes 10 seconds instead of milliseconds. Labview 2020, same in 2016.
05-11-2021 04:13 PM - edited 05-11-2021 04:27 PM
I'm with RavensFan. It's time to back up, slow down and describe this problem clearly and thoroughly.
You say, "I am searching large Array for a match in the generated array, it's that simple." But your *code* shows you doing the opposite -- searching through the generated array for each of the elements contained in the large fixed array. That's 500k searches through a 50k array and you're trying to do it once a second?
From the limited info you've given so far, this *sounds* like a problem that would be better off using a Map rather than an array. A Map's lookup performance is logarithmic with size rather than linear, and with a 500k size that's likely to make a pretty huge difference.
-Kevin P
05-11-2021 04:20 PM - edited 05-11-2021 04:28 PM
I am generating random words 50 k per second. Looking for a match in the large array that is read from file but it's all irreverent. There appears to be a bug. No matter what I search for, anything is size, wiring the index to a condition or output to for loop kills the search speed by a factor of 1000.
05-11-2021 04:39 PM
I have tried it reversed as you suggested and the problem the remains. The issue is not apparent until you try and wire the index terminal to anything, including an indicator. Yes, once a second. The large file is read from disk and shift registered. I want to see if any of the generated words matched the file. You're correct that it's reversed but I was just playing around to observe behavior. You can reproduce the behavior if you wire the index terminal from the search 1d.
05-11-2021 04:46 PM
Very easy to fix this. Sort your 500k array (or load it already sorted) then use a binary search to find the random words.I get 100-1000x speedup, and it should be fairly constant for all words, whereas the ordinary Search varies depending on where the word is in the array.
05-11-2021 04:55 PM
Thanks, the Big Array is sorted. Is there an example of a binary search?
05-11-2021 04:58 PM
@n2new wrote:
Thanks, the Big Array is sorted. Is there an example of a binary search?
If you're in LabVIEW 2020, you can use the Search Sorted 1D Array.vim.
05-11-2021 04:59 PM
Here you go. It's modified from one I found, but not sure where, so apologies if I haven't acknowledged someone for it.
05-11-2021 05:08 PM
I was looking at that function. How to convert String array to polymorphic?