|
|||||
|
|
#1 |
|
|
|
|
|
#2 |
|
|
"Gaurav" <gaurav_7_7@yahoo.com> schrieb im Newsbeitrag news:7113e26f.0406152345.2f01b86c@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 ****py 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 |
|
|
#3 |
|
|
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 |
|
|
#4 |
|
|
On 16 Jun 2004 00:45:02 -0700, gaurav_7_7@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 |
|
|
#5 |
|
|
Gaurav wrote:
> http://www.sys-con.com/story/print.cfm?storyid=45250 > > Any comments? LoL, the guy who wrote that knows absolutely nothing about benchmarking. br db |
|
|
#6 |
|
|
Gaurav wrote:
> http://www.sys-con.com/story/print.cfm?storyid=45250 > > Any comments? > Those tests expose one regularity - the examples where OS support is extensively used are slower than those where the entire code in performed in process space. Performance of the former suffers from user/kernel mode switching and if it is done at least once per loop iteration the impact must be pretty visible. So all C++ examples with extensive heap or stack (function calls) memory allocation must be slower than corresponding Java examples where similar functionality is performed by the JVM directly in the user process space (Fibonacci, hash, object creation). Of course if one is ready to pay with slower startup and bigger memory consumption then he/she may can have the same in C++ using inlining, memory pool and other commonly used techniques. When such handicaps are not introduced (nested loop, random numbers) C++ performs faster as expected. One thing surprised me. For the reason described above I expected the method call example to be slower in any case in C++ than in Java, then after looking at the code it appeared that all member functions were coded inline and at least some of them were optimized away by the compiler. So this test does not fulfil its goal. The other ones also introduce some unnecessary temporary variables etc. and should not be used as representative C++ code. Regards, J****z |
|
|
#7 |
|
|
"Gaurav" <gaurav_7_7@yahoo.com> wrote in message news:7113e26f.0406152345.2f01b86c@posting.google.c om... > http://www.sys-con.com/story/print.cfm?storyid=45250 > > Any comments? > I was recently part of a team that rewrote an largish C++ app in Java. No question that for this application the Java version was slower than the C++ version. No doubt the Java version had some advantages (platform independence for instance) but it was slower and noticeably so. john |
|
|
#8 |
|
|
Gaurav wrote:
> http://www.sys-con.com/story/print.cfm?storyid=45250 > > Any comments? > In general, you can find arguments to many unfounded things. Weather this is correct (which I doubt) or not is irrelevant most of the time. Don't worry about it unless you need to. Barely related question. How many of you guys actually work on projects in which performance is critical? (Something written in Java is unacceptable) I see value in both languages, however, it appears as though many people immediately dismiss Java, regardless of the scope and requirements of the project. JLR |
|
|
#9 |
|
|
> How many of you guys actually work on projects in which performance is > critical? (Something written in Java is unacceptable) When you write a conventional user application for a multitasking system, your program should accomplish its tasks as fast as possible. Therefore, we are commited to deliver the fastest software ever. 0.01ms vs. 0.1ms responce on user button c**** is much more important for us as opposed to development time. Therefore, we write huge number of code lines and ignore impressing IDEs like Intellij Idea and go on wasting our time and writing unreliable code in order to deliver the best performance. Slow C++ compiler does lots of things for us including and compiling huge files. |
|
|
#10 |
|
|
Gernot Frisch wrote:
> ✄ > you will see that you can do everything you do in Java in C++ but not viceversa. So there are something that may be do in C++ and not in Java? Interesting... Please give me your curriculum, so I can hire you in my company! - Dario |