Search in

Sort by:

Everything Blueprint Scripting

Current Space

Question Status:

All Questions With Answer With Accepted Answer

Quick results

Search help

Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both.
Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.

You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with
each other. Examples

Why is the Array Find function so fast?

0

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?

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.

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?

Yeah, I know how to make binary heaps but that Find function can work on any variables like structs so I'm just surprised on its speed when I tested it. I was using 4-ary search on my pathfinding algorithm though it only works on numbers.

the fact that the find function is defined in C++, and your find function probably is made in blueprints usually makes difference, as blueprints have less performance than C++ (hard to say exactly how much C++ is faster than blueprint), besides this, we would need to look at how exactly both functions works to compare.

Yeah I just tested it in ue4 c++ and it's faster there, I'm probably gonna move to c++ lol, I thought bp wouldn't have much difference. And in c++ I can loop 1,000,000 array without the engine calling for callstack and even 1,000,000 don't have an impact in the fps lol, in BP 1000 loop starts having an impact. and 100,000+ loop will call a callstack.