3 ms·
Very cool. I believe that this is a very instructive piece of code to introduce in a concrete way what a compiler does to optimize your code, at least to unexpe
by jiiam 10y ago
Very cool. I believe that this is a very instructive piece of code to introduce in a concrete way what a compiler does to optimize your code, at least to unexperienced people like myself.
I'm very amazed by the simplicity of this example. Are there more serious optimization that can be seen with simple code?
- rkangel 10y agoTry this: http://stackoverflow.com/questions/11227809/why-is-processing-a-sorted-array-faster-than-an-unsorted-array http://stackoverflow.com/questions/11227809/why-is-processin... Have a look at the "Update" to the top answer, specifically what the intel compiler does.
- bathory 10y agoIt should be noted though, that the actual branch prediction comes from the CPU, not the compiler.