3 ms·
If you care about performance and the number of if's you should look into profile guided optimization. This can help the compiler to arrange the code such that
by solarexplorer 5y ago
If you care about performance and the number of if's you should look into profile guided optimization. This can help the compiler to arrange the code such that branches like the "if (debug)" in the example, are never taken and so don't occupy precious resources. This will also make instruction fetch faster and if the body of the if is placed on another cache line it can also improve instruction cache performance (and even TLB performance and IO performance if the unused code is placed into another page).
https://llvm.org/docs/HowToBuildWithPGO.html https://llvm.org/docs/HowToBuildWithPGO.html