Tom Ritchford
Nov 1, 2023

--

Skeptical here.

If you need to process 100k numbers, something will run 100k times. Maybe you will get a bit speedup from a vector processor, or a GPU, or some bit of specialized hardware that will help you, but 100k operations will be performed.

More, the sorts of optimizations that the C++ compile can do are not generally able to reduce the number of iterations in a loop. Yes, loops with a small number of iterations can be unrolled, but the same number of operations is performed, it's simply done in a more efficient manner.

The original question is not, "Why does iterating through a sorted array faster in every single case?" It is, "Why in this specific case do I see a speedup?"

--

--

No responses yet