3 ms·
it's better to let the compiler decide (with gcc, you build a branch profile version, then rebuild the code with profiling results). unless you have something u
by foxhill 13y ago
it's better to let the compiler decide (with gcc, you build a branch profile version, then rebuild the code with profiling results). unless you have something unusual, and have some deep insight into your code (unlikely), you're not going to do better than the compiler.
- scott_s 13y agoI find it strange you find it so unlikely that people have that much insight into their own code. The code I work on has several instances of likely/unlikely in the main path for cases that we know happen either once, rarely, or when we are moving off the optimized path.
- ris 13y agoHave you tried benchmarking it against a non-annotated compiled version?
- scott_s 13y agoI have not, but I believe those who originally wrote it did.
- foxhill 13y agoi've never came across code that has performed better with manual hints than compiler profiling. at best, you can match the compiler, but.. i find that improbable, unless you have only a handful of branches.
- scott_s 13y agoThese are situations where the branch will be taken, literally, millions of times in one direction, and once in the other.