Loop Unrolling Performance
Discussions center on the performance benefits of manual loop unrolling versus compiler-optimized loops, including debates on overhead reduction, branch predictions, and examples across languages like C and JavaScript.
Activity Over Time
Top Contributors
Keywords
Sample Comments
What's not worth it? Loop unrolling? Something else?
It's called loop unrolling and improves performance by eliminating loop control overhead and reducing branch mispredictions. Maybe they had a compiler background :)? /s
I thoughr this trivial stuff like loops doesn't really matter anymore due to compilator optimizations. Isn't that the case?
And it would be an order of magnitude slower than plain loop because compiler is not smart enough to optimize it.
Except when loops unrolls make things faster.
I wonder if this is really faster than just writing it as a loop.
That seems like a loop.It is slow it is rarely used it doesn't get optimized it is slow
Doesn't that involve just as much looping as any other solution?
The second I learned this trick, many years ago, I've used it in everything. The argument that it's "slow" is ridiculous. It's like using while(i--) instead of a for() to shave 0.0000001 milliseconds off your javascript loops. Just admit you have OCD and move on ;)
You're comparing apples and oranges. Of course modifying an array or copying it takes way more time than looping. The comparison was not about that, it's about one loop with 10 instructions VS 10 loops each with a single instruction, for the exact same instructions.