LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 673|回复: 1

关系运算符的效率问题

[复制链接]
发表于 2010-7-24 11:13:59 | 显示全部楼层 |阅读模式
">=" "<=" 和 ">" "<" 哪种关系运算符的效率更高?

据说有资料说是
"<" 和">" 要比 ">=" "<=" 效率高

不知是否属实
 楼主| 发表于 2010-7-24 11:43:27 | 显示全部楼层
汇编代码
">"
main:
20         leal    4(%esp), %ecx
21         andl    $-16, %esp
22         pushl   -4(%ecx)
23         pushl   %ebp
24         movl    %esp, %ebp
25         pushl   %ecx
26         subl    $20, %esp
27         movl    $3, -8(%ebp)
28         movl    $2, -12(%ebp)
29         movl    -8(%ebp), %eax
30         cmpl    -12(%ebp), %eax
[color="Red"] 31         jl      .L4
32         call    ccc

">="
19 main:
20         leal    4(%esp), %ecx
21         andl    $-16, %esp
22         pushl   -4(%ecx)
23         pushl   %ebp
24         movl    %esp, %ebp
25         pushl   %ecx
26         subl    $20, %esp
27         movl    $3, -8(%ebp)
28         movl    $2, -12(%ebp)
29         movl    -8(%ebp), %eax
30         cmpl    -12(%ebp), %eax
[color="red"] 31         jle     .L4
32         call    ccc

.L4部分
汇编代码是相同的
33 .L4:
34         movl    $0, %eax
35         addl    $20, %esp
36         popl    %ecx
37         popl    %ebp
38         leal    -4(%ecx), %esp
39         ret

都是一条汇编指令
看来">="和 ">"的效率是差不多的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表