关于++ i和i ++之间的表现 [英] about performace between ++i and i++
问题描述
你好!!
哪个在i ++或++ i之间有最好的表现。
它是完全相同还是在一些非常小的差别表演
betwwwn这两个。
// Tony
Hello!!
Which have best performance between i++ or ++i.
Is it exact the same or is it some very small difference in performace
betwwwn these two.
//Tony
推荐答案
" Tony Johansson" <乔***************** @ telia.com> écritdansle message de
news:bu *************** @ newsb.telia.net ...
|其中i ++或++ i之间的性能最佳。
|是完全相同还是性能差异很小
|这两个人之间的关系。
比较两个完全不同的运营商的绩效有什么意义
?
如果你想在使用它之后增加它,那么使用i ++。
如果你想在使用它之前增加它,那么使用++ i。
性能真的不是问题所在。
Joanna
-
Joanna Carter [TeamB]
顾问软件工程师
"Tony Johansson" <jo*****************@telia.com> a écrit dans le message de
news: bu***************@newsb.telia.net...
| Which have best performance between i++ or ++i.
| Is it exact the same or is it some very small difference in performace
| betwwwn these two.
What''s the point of comparing performance on two totally different operators
?
If you want to increment the value after using it, then use i++.
If you want to increment the value before using it, then use ++i.
Performance really isn''t the issue here.
Joanna
--
Joanna Carter [TeamB]
Consultant Software Engineer
" Tony Johansson" <乔***************** @ telia.com>写道:
"Tony Johansson" <jo*****************@telia.com> wrote:
哪个在i ++或++ i之间有最好的表现。
它是完全相同还是性能差异很小
这两个。
Which have best performance between i++ or ++i.
Is it exact the same or is it some very small difference in performace
betwwwn these two.
显然,当在一个使用其值的表达式中使用时,这些语义具有不同的语义,所以我不会谈论那个。
作为独立的表达式语句,它们分别编译为跟随IL的
,其中''i'是唯一的本地
变量:
i ++;
ldloc.0
ldc.i4.1 >
add
stloc.0
++ i;
ldloc.0
ldc.i4.1
add
stloc.0
i = i + 1;
ldloc.0
ldc.i4.1
add
stloc.0
i + = 1;
ldloc.0
ldc.i4.1
add
stloc.0
所以,没有区别。
>
- Barry
-
http://barrkel.blogspot.com/
Obviously, when used in an expression whose value is used, these have
different semantics, so I won''t talk about that.
As freestanding expression statements, they are compiled to the
following IL, respectively, where ''i'' is the one and only local
variable:
i++;
ldloc.0
ldc.i4.1
add
stloc.0
++i;
ldloc.0
ldc.i4.1
add
stloc.0
i = i + 1;
ldloc.0
ldc.i4.1
add
stloc.0
i += 1;
ldloc.0
ldc.i4.1
add
stloc.0
So, there is no difference.
-- Barry
--
http://barrkel.blogspot.com/
你好!!
那是回答我想要的,而不是我从乔安娜那里得到的答案
// Tony
" Barry Kelly" < BA *********** @ gmail.com> skrev i meddelandet
新闻:jc ******************************** @ 4ax.com ...
Hello!!
That was the answer I wanted and not the answer I recived from Joanna
//Tony
"Barry Kelly" <ba***********@gmail.com> skrev i meddelandet
news:jc********************************@4ax.com...
" Tony Johansson" <乔***************** @ telia.com>写道:
"Tony Johansson" <jo*****************@telia.com> wrote:
哪个在i ++或++ i之间有最好的表现。
它是完全相同还是性能差异很小
这两个。
Which have best performance between i++ or ++i.
Is it exact the same or is it some very small difference in performace
betwwwn these two.
显然,当在一个使用其值的表达式中使用时,它们具有不同的语义,所以我不会谈论它。
作为独立表达式语句,它们分别被编译到IL />,其中我是唯一的本地变量:
i ++; < brd> ldloc.0
ldc.i4.1
添加
stloc.0
++ i;
ldloc.0
ldc.i4.1
添加
stloc.0
i = i + 1;
ldloc.0
ldc.i4.1 >添加
stloc.0
我+ = 1;
ldloc.0
ldc.i4.1
添加
stloc.0
所以,没有区别。
- 巴里
-
http://barrkel.blogspot.com/
这篇关于关于++ i和i ++之间的表现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!