Java的性能远优于优化的C ++ [英] Java's performance far better that optimized C++

查看:58
本文介绍了Java的性能远优于优化的C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://www.sys-con .com / story / print.cfm?storyid = 45250

有任何意见吗?


谢谢

Gaurav

解决方案



" Gaurav" < GA ******** @ yahoo.com> schrieb im Newsbeitrag

新闻:71 ************************** @ posting.google.c om ...

http:// www.sys-con.com/story/print.cfm?storyid=45250

任何评论?

感谢
Gaurav




Huhuhu-hahaha ......

Java更快...哈哈...比C ++ ... ha-hahaha ......


第一个。如果你仔细看看语言功能,你将会看到你可以用C ++做的所有事情,而不是副词

。接下来,如果你优化编译器的代码不能比你提供的糟糕的C ++更好。所以,如果你真的想要比较2,你应该为每种

语言获得2个专业的程序员,并让每个人按照他们的语言要求进行操作。 />
接下来,gcc 3.3并不是一个很好的优化编译器。优于

2.95,但不如英特尔或codewarrior编译器那么好。

但是对于周三的mornig,一个好笑话,谢谢。


-Gernot


Java中的代码不能比C ++中的代码快,因为使用C ++生成了

代码实际上是100%最优的,前提是程序是用b / b写的,并且编译器很好。还有很好的

编译器。


祝你好运,

Marcin


2004年6月16日00:45:02 -0700, ga ******** @ yahoo .com (Gaurav)写道:

http://www.sys-con.com/story/print.cfm?storyid=45250

任何评论?



每当我详细查看语言间基准时,我总会在一种语言或其他语言的基准测试中发现

a缺陷(通常是

两者),通常基于作者的偏见(他们一般用一种语言比另一种语言有更多的专家)。


在你发布的基准测试中,提供给GCC

的编译器选项是次优的,并且似乎没有内联函数声明。

例如,许多测试我从循环展开中受益,

只发生在-O3上我认为。一些基准测试也是高度合成的(除了尝试以真正的方式从未发生过的方式轰炸

a特定语言功能)他们什么都不做。 br $> b $ b程序)。最好为输入设置一个必需的输出,然后

让程序实现该输出,但它希望平衡

代码清晰度和优化。 br />

很明显,我使用

这个简单的代码将斐波那契测试降低到0.1秒左右:


unsigned long fib(unsigned long n){

unsigned long last = 1;

unsigned long current = 1;

for(unsigned long i = 2 ; i< = n; ++ i)

{

unsigned long newCurrent = last + current;

last = current;

current = newCurrent;

}

返回当前值;

}


Tom

-

C ++ FAQ: http://www.parashift.com/c++-faq-lite/

C常见问题: http://www.eskimo.com/~scs/C-faq/top.html

http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?

Thanks
Gaurav

解决方案


"Gaurav" <ga********@yahoo.com> schrieb im Newsbeitrag
news:71**************************@posting.google.c om...

http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?

Thanks
Gaurav



Huhuhu-hahaha...
Java faster ...haha... than C++ ...ha-hahaha...

First of. If you take a close look at the language features you will
see that you can do everything you do in Java in C++ but not vice
versa. Next, if you "optimize" code by the compiler it can''t become
any better than the crappy C++ you provide. So, if you want to really
compare the 2, you should get 2 professional prograamers for each
language and let each one do the way their language requires doing.
Next, gcc 3.3 is not really a good optimizing compiler. Better than
2.95, but not as good as say the intel or the codewarrior compilers.
But for a wednesday mornig, a good joke, thank you.

-Gernot


The code in Java cannot be any faster than in C++, because with C++ the
generated code is practically 100% optimal, provided that the program is
written with it in mind, and the compiler is good. And there are good
compilers out there.

Best regards,
Marcin


On 16 Jun 2004 00:45:02 -0700, ga********@yahoo.com (Gaurav) wrote:

http://www.sys-con.com/story/print.cfm?storyid=45250

Any comments?



Whenever I look at inter-language benchmarks in detail, I always find
a flaw in the benchmarking for one language or the other (and often
both), generally based on the author''s bias (they generally have
greater expertese in one language than the other).

In the benchmarks you''ve posted, the compiler options provided to GCC
are sub-optimal, and no functions seem to have been declared inline.
For example, many of the tests would benefit from loop unrolling,
which only happens on -O3 I think. Some of the benchmarks are also
highly synthetic (they don''t really do anything except try to bombard
a particular language feature in a way that never happens in a real
program). It''s better to set a required output for the input, and then
let the program achieve that output however it wishes to, balancing
code clarity with optimization.

Incidently, I got the fibonacci test down to around 0.1 seconds using
this simple code:

unsigned long fib(unsigned long n) {
unsigned long last = 1;
unsigned long current = 1;
for (unsigned long i = 2; i <= n; ++i)
{
unsigned long newCurrent = last + current;
last = current;
current = newCurrent;
}
return current;
}

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html


这篇关于Java的性能远优于优化的C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆