c - Operator performance in loops -
C: operator ! =
or & gt;
? I am asking if we have a large amount of weights and one of the above situations ( while (x! = - 1)
or while (x> 0)
).
Also about other languages.
Processors on most modern ones will not make any difference
This is usually a comparison Compiled in the form of instruction, which make some flags, after which there are branches on the combination of some flags. There is usually no time difference between the relational operator.
Some customizable branches can leave the jump, but then it is not possible to tell which operator will be more demonstrative, if any. This probably depends on the context.
Of course, if you really want to know, then you have to run some tests and / or code profiles.
Comments
Post a Comment