Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

But that's repeated in the loop. So, looks like around a 10-20% performance change. Quite a bit for something not obvious.


Perhaps in a really tight loop but the counter is still going to be several iterations ahead thanks to the out of order capabilities of the CPU. You may also have other things in play as well such as the micro-op cache depending on the code size of the loop.


The worst case is extending the counter each time it's changed, which is once per loop. It's not going to be a measurable difference unless the loop is tight enough to take like 3 cycles per iteration or less.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: