4 ms·
Iterating a long array twice to do two simple things can often be faster than iterating once to do a more complicated thing. See for example https://stackoverfl
by yxhuvud 9y ago
Iterating a long array twice to do two simple things can often be faster than iterating once to do a more complicated thing. See for example https://stackoverflow.com/questions/8547778/why-are-elementwise-additions-much-faster-in-separate-loops-than-in-a-combined-l https://stackoverflow.com/questions/8547778/why-are-elementw... .
The wonders of modern processors and compilers.
- taeric 9y agoThat link is more about the pitfalls of page alignment. Caches being a very dangerous topic. Getting the data aligned in a cache friendly way returns those loops to the expected behavior of one iteration being faster than two.