Closed bouk closed 8 months ago
Is this essentially saving you 5ms on the 4896×3264 image? That's a nice improvement.
Could you explain in the commit message a bit what the change is doing and why it improves the performance? Glancing over this, Isee it's moving the parent
and size
from the struct ufrec
into the struct unionfind
, turning them into a point for arrays and then initialising all elements in the list at once instead of looping over the array of struct ufrec
?
Expanded the commit message a bit. The savings is indeed from using memset
instead of a for loop
Can you remove the concrete ~4% from the commit message again? I guess this value depends a lot on the image resolution and is not the same improvement in all cases.
Sure, removed
Thanks!
I figured out that a big part of the union find time spent was initializing the data array. I've optimized it by using two
memset
s instead of an array, which saves ~4% for an image sized 4896×3264Before
After