c - condition vs division -
c - condition vs division -
given next statement executed lot:
inormval = ival / uratio;
would next create more sense (performance wise) if uratio == 1
(90%) of time?
if(uratio > 1) inormval = ival / uratio; else inormval = ival;
thanks..
you need profile measurement, it's hard guess. compiler might decide you're wrong , remove test, check , without optimizing.
the actual cost of (integer) partition might rather low, on modern desktop-class processors. according this pdf, costs on modern (wolfdale/nehalem/sandy bridge) of 32/32-bit partition 14-23/17-28/20-28 cycles respectively. so, if lot, might add together up. in case, parallel (vectorized) options if possible.
i seek avoid if @ possible, since introduces branch. branches have 2 disadvantages: create code more complex introducing multiple paths programmer reading code has understand, , can introduce execution overhead.
c performance division
Comments
Post a Comment