3 ms·
Interesting test, but it's not news if you know something about code optimization. Caching of the data may also play a part on similar cases (but not this one
by raverbashing 14y ago
Interesting test, but it's not news if you know something about code optimization.
Caching of the data may also play a part on similar cases (but not this one - or better, the effect is negligible)
Here's a little test that can be tried. Make the test result (inside the if) be true or false alternately (for example, sum only if the index is even), see how long it takes.
Spoiler: modern branch predictors can detect and predict cyclic conditions