javascript - Efficient way to compare to zero -
Condition: When there is a circle, where there are some numeric variables (i.e. Thanks Toraezboobo Or other options? You are probably optimizing the micro and the cost of a comparison against zero in any major program There is no possibility to see the big difference. However, for the sake of science ... The most common optimization (for loop optimization, writing variables etc.) and to call the blackhole (ISH) function, the benchmark written by @EbrrahmedM Instead of tweaking, I might see an important difference: How they work due to the results: moreThanZero ) a zero (Usually more than ...) many cycles, more than a million say, what is the most effective / fast way to compare:
If (MoreThanZero) { ...} If (moreThanZero> 0) {...} If (moreahairro! = 0) {...} If (more sharps! == 0) {...}
if (0! == moreThanZero) {...}
! N At least testing the specific operation at least, this (in some fashion) must treat the variable as a boolean. Some optimizations can be done and some compilers may be smart enough to use a little or no numerical comparison, but a lot of work is allowed in the language.
=== and
! == There are obviously no rape types, so they are likely to be reliably fast, with the warning that both operands should be of the same type or they are not equal. For numbers, this is likely to be an integer comparison, which should be placed below the
cmp command.
& gt; May, and possibly, optimize the benefits of modern browsers, when both operands are considered numeric and especially integral. Stable, especially compared to 0, is an ideal case: a assembly instruction that compares to 0.
Comments
Post a Comment