3 ms·
But why does the print statement matter in how the compiler decides this? In both cases, the execution still depends on the vMax value calculated in the previou
by mcv 3y ago
But why does the print statement matter in how the compiler decides this? In both cases, the execution still depends on the vMax value calculated in the previous iteration.
- Majromax 3y agoThe version with the print statement requires the branch because it's conditionally executed; the 'continue' statement in the if-block will skip it if the loop finds a new maximum. Since the function-with-if version requires a branch, there's no advantage (regardless of predictability) in using a conditional move for the assignment to maximum.
- kaba0 3y agoSo basically the print prevents an optimization, that so happens to hinder performance in this particular case?