Why isn't minmax branchless?

I think your benchmark is skewed by the fact that you’re always using the same data. The branch predictor in your CPU is probably picking up the patterns in your data and messing with your result. I’d create a new array for each benchmark run using the setup keyword of @benchmark. It should still even out statistically, but it’ll make it much harder for the branch predictor to mess with things.

5 Likes