|
[求助]请问如何判断i++与++i哪一个运行更快
这里,有没有人精通编译原理呢? 他应该知道哪个执行快。 |
|
[求助]请问如何判断i++与++i哪一个运行更快
加1用inc吧 用add EAX,1 相对来说慢吧?所以说反汇编出来的代码与汇编写的代码是不同的,从反汇编的代码上看i++与++i哪个执行更快是不合理的 |
|
[求助]请问如何判断i++与++i哪一个运行更快
耗时,不是执行顺序。执行顺序,包括k=1+(i++);k=1+(++i)我理解 |
|
[求助]请问如何判断i++与++i哪一个运行更快
我想我没表达清楚,我的意思是:如果我用汇编写代码,想表达与i++相同的代码是不是也是如同反汇编出来的那样, MOV EAX,DWORD PTR SS:[EBP-4] ADD EAX,1 MOV DWORD PTR SS:[EBP-4],EAX 走三步,还是有更优化的方法? |
|
[求助]请问如何判断i++与++i哪一个运行更快
似乎有资料称EAX比ECX执行速度更快,所以编程时优先考了EAX |
|
[求助]请问如何判断i++与++i哪一个运行更快
如果不参与其他的运算只是像我代码中的 #include <iostream.h> void main() { int a; a++; ++a; cout<<"Finsh"<<endl; } 两者执行速度或者说执行耗时是不是一样的? |
|
[求助]请问如何判断i++与++i哪一个运行更快
不对吧,i++与++i使用的寄存器没有什么不同,当i++在前时,或++i在前时 都是先使用EAX寄存器。 |
|
[求助]请问如何判断i++与++i哪一个运行更快
我可不可以这样理解? 对于i++与++i两者执行的速度是一样的,因为二者对应的汇编代码只是执行的顺序不同。但在参与其他运算的时候,++i比i++先完成运算。 对否? |
|
|
|
[求助]请问如何判断i++与++i哪一个运行更快
[QUOTE=大菜一号;348890]如果代码写成 因为会先自加一,再进行运算,i++则用i去运算,再自加一QUOTE] 也就是说:i++与++i执行的速度是一样的都是各经过一次加一与参与运算,两者的区别只在于参与其他运算的时候的执行的顺序是不一样的? 如果从概念上讲我比较赞同此说法,但如果从汇编上,甚至机器码上看对于不参与其他运算的i++与++i的执行有区别么? |
|
[求助]请问如何判断i++与++i哪一个运行更快
补充一个问题:反汇编出来的代码与VC对应的汇编代码是一回事儿么? |
|
[求助]请问如何判断i++与++i哪一个运行更快
但是那是反汇编出来的代码,还是就是VC对应的汇编代码? 我尝试 #include <iostream.h> void main() { int a; a++; ++a; cout<<"Finsh"<<endl; } 用OD OllyIce VC反汇编出来的都是 MOV EAX,DWORD PTR SS:[EBP-4] ADD EAX,1 MOV DWORD PTR SS:[EBP-4],EAX MOV ECX,DWORD PTR SS:[EBP-4] ADD ECX,1 MOV DWORD PTR SS:[EBP-4],ECX 然后将VC中的CODE变为 #include <iostream.h> void main() { int a; a++; ++a; cout<<"Finsh"<<endl; } 反汇编出来的还是 MOV EAX,DWORD PTR SS:[EBP-4] ADD EAX,1 MOV DWORD PTR SS:[EBP-4],EAX MOV ECX,DWORD PTR SS:[EBP-4] ADD ECX,1 MOV DWORD PTR SS:[EBP-4],ECX 难道a++与++a一样? 另有人说a++是先复制内容再进行加1,然后复制回去,而++a是直接在原位置执行+1。所以++a比a++要快。真的是这样?我们for的时候多是用i++么? 到底哪个更快?? |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值