c - i++, i=i+1 and i+=1 which one is faster? -
this question has answer here:
- incrementing: x++ vs x += 1 5 answers
i'm curious know 1 run fastest in cpu among i++
, i+=1
, i=i+1
, how can measure execution time?
well, @ first mankind invented following record.
i = i+1;
then along achievments in hardware mainkind invented following record
i += 1;
and @ last due progress in computer sciences mankind invented following records
++i;
and
i++;
all these 3 forms of records expressions of same set of machine instructions.(with minor exception ++i , i++ when parts of more complex expression):) , set of machine instructions not depend on level of compiler optimization.:)
p.s. of course discussing these operators fundamentals types. there no sense discuss these operators user-defined types because can overloaded in various ways.
Comments
Post a Comment