vendredi 30 novembre 2018

Performance for compound boolean vs. unlikely/likely

Is doing this faster?:

return m_bVisible && (_colorTransform.alphaTransform > 0 || _colorTransform.colorOffsetTransform.a > 0) && (!_masked || _maskVisitable);

Than doing this?:

if (UNLIKELY(_colorTransform.alphaTransform == 0 && _colorTransform.colorOffsetTransform.a == 0))
{
    return false;
}

if (UNLIKELY(_masked && !_maskVisitable))
{
    return false;
}

return m_bVisible;

Doing a lot of minor optimizations which have improved framerate performance significantly for our game, here's one that I'm unsure of. I'm ok with getting 0.01% performance gain since after doing 100 of these optimizations, I've been able to improve performance quite significantly(30-40%). Asking about the use of UNLIKELY optimization vs. just the compound boolean. Short circuiting isn't very easy to do in this particular expression.

Aucun commentaire:

Enregistrer un commentaire