开发者

Time-consuming operation

开发者 https://www.devze.com 2023-02-19 02:05 出处:网络
if I have two integer variables with allocated memory and value a and b, which 开发者_StackOverflow中文版is the more time consuming (time of execution by the processor) operation: comparison (a == b)

if I have two integer variables with allocated memory and value a and b, which 开发者_StackOverflow中文版is the more time consuming (time of execution by the processor) operation: comparison (a == b) or assignment (a = b) ? And why?


It probably depends on your processor architecture and the resulting binary executable.


Because the assignment involves a memory write (assuming that a is not a local value held in a register), chances are that it is slower on contemporary processors.

0

精彩评论

暂无评论...
验证码 换一张
取 消