Search in
Sort by:

Question Status:

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
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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?

Product Version: UE 4.15
more ▼

asked Feb 21 '17 at 09:43 PM in Blueprint Scripting

avatar image

344 10 12 21

avatar image Furroy Feb 22 '17 at 04:15 PM

Newer engine versions have maps in addition to arrays. If you could use a key lookup in place of find, presumably it would be much faster.

avatar image veccher Feb 22 '17 at 04:20 PM

good point furroy, i remember Alexander Pascal saying it was faster than arrays when you're trying to use a large amount of itens.

avatar image Maslobojik Sep 28 '17 at 03:37 PM


(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

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.

more ▼

answered Feb 22 '17 at 04:52 AM

avatar image

35.2k 921 166 1098

(comments are locked)
10|2000 characters needed characters left

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?

more ▼

answered Feb 22 '17 at 12:55 AM

avatar image

1.1k 31 16 65

avatar image kurosu143 Feb 22 '17 at 01:21 AM

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.

avatar image veccher Feb 22 '17 at 03:12 AM

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.

avatar image kurosu143 Feb 22 '17 at 04:43 AM

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.

avatar image veccher Feb 22 '17 at 03:49 PM

remember that you can try to use blueprint nativization if your problem with blueprints is performance. it will try to convert the blueprint code to C++ while packaging.

(comments are locked)
10|2000 characters needed characters left
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question