Why is the Array Find function so fast?
The Array Find function can find an item in the 100,000+ array without affecting fps in the event tick. But when I create a function using ForEachLoop that checks every element and compare to the one I need or while loop, my fps drops to less than 10. Is there any other way to find item in the array that's really fast?
asked Feb 21 '17 at 09:43 PM in Blueprint Scripting
C++ imlementation is not much diffrent of what you do in blueprint:
ForEachLoop runs in virtual machine and each loop takes longer as it need to do blueprint execution, find function runs nativly on full speed, but still it's not healthy practice to do it on tick, should be avoided.
answered Feb 22 '17 at 04:52 AM
there's a lot of things to improve performance in searchs, adding code to the loop = losing performance per loop, also you can search about searching algoritms, checking every item of a 100,000+ array surely will take a lot of time, search about algorithms like "binary search" (it requires that the array is ordered). about the "find" function, i don't know exactly how it works, so i can't talk about it specifically, if it's working so fine, why you don't use it?
Follow this question
Once you sign in you will be able to subscribe for any updates here