比较运算符的速度 [英] Speed of Comparison operators
本文介绍了比较运算符的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在诸如……之类的语言中,两个运算符均<和< =(及其对立)存在.哪个会更快,以及如何解释它们?
In languages such as... well anything, both operators for < and <= (and their opposites) exist. Which would be faster, and how are they interpreted?
if(x< = y){等等; }
if (x <= y) { blah; }
或
if(x< y + 1){等等; }
if (x < y + 1) { blah; }
推荐答案
假定没有编译器优化(大的假设),第一个将更快,因为< =由单个jle
指令实现,而后者需要加一个jl
指令.
Assuming no compiler optimizations (big assumption), the first will be faster, as <= is implemented by a single jle
instruction, where as the latter requires an addition followed by a jl
instruction.
http://en.wikibooks.org/wiki/X86_Assembly/Control_Flow#Jump_if_Less
这篇关于比较运算符的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文