5 ms·
Also, modern processors might run the code anyway and trow away the path not taken. Its better to optimize by generating a function that does not have branches.
by z3t4 6y ago
Also, modern processors might run the code anyway and trow away the path not taken. Its better to optimize by generating a function that does not have branches.
- mrec 6y agoI don't think that applies to conditional rendering, does it? You can't speculatively execute a graphics API command buffer submission and then dash after it shouting "wait, come back, I didn't mean it". Same with any kind of I/O, I'd think.
- z3t4 6y agoYou are correct. But the same strategy can be used for optimization. Eg. get rid of the whole if block, and preferably dependencies to make it pure so that it can be further optimized by caching the output. Although cpu can be faster then cache so always measure.
- himinlomax 6y agoThat only happens for a few consecutive instructions at most.