No Branch
for (auto i = 0u; i < arr.size(); ++i) {
if (arr[i] > 128)
sum += arr[i];
}
^ This is Faster?
for (auto i = 0u; i < arr.size(); ++i) {
sum += arr[i] * (arr[i] > 128);
}
^ This is Faster?
* The benchmark is run under AMD Ryzen 9.
* For the full benchmark code, please refer here.
* For illustration purposes only, see FAQ for more details.