TObjectIterators the speedy-er way
So as best I understand, in general using
is bad - it's not a good idea to iterate all the UStaticMeshComponents (in a fresh save there's about 10k of them) or whatever other component you want to iterate over, but sometimes it seems somewhat unavoidable for whatever reason. I just wanted to share the results of my profiling in case it helps
This simple approach takes between 5-7ms to run on my PC.
1 Reply
Comparatively, separating out the iteration and the performing some of the operations in parallel, this takes <1ms to perform the same task on a CPU with 6 cores.
If you have an even larger list to work through, rather than using a mutex in the loop you can make thread-local variables to store the results of each parallel operation in and just batch write/append the results at the end of processing to your other variable. There's quite a bit of information of all its capabilities in the
ParallelFor.h
header and examples online for more information.
There's likely other things that can be done to further improve this - this is the result of my reading and experimentation so far