Irrlicht3d.org
::
Blog
|
About Me
|
Twitter
Add comment for
C++ vs. Java 1.6 - A fair Benchmark
Posted by:
Enter the missing letter in: "Internat?onal"
Text:
[quote][b]Andy Tripp[/b] wrote: You never mentioned which C++ compiler you're using. That could make a big difference. Using g++ 3.4.4 on Windows under Cygwin with -O3 option, I get these times: fib: 17341 heap: 4770 nest: 4628 copy: 1932 Here is the code to use the non-MS-specific gettimeofday() call: struct timeval tv1; struct timeval tv2; cout << "testing " << testName << "...\t\t"; gettimeofday(&tv1, 0); // run test int retValue = toTest->test(); gettimeofday(&tv2, 0); delete toTest; long diff = (tv2.tv_sec - tv1.tv_sec)*1000 + (tv2.tv_usec - tv1.tv_usec)/1000; cout << diff << "ms. (calculated result: " << retValue << ")\n"; Here are the times I get for Java: fib: 10282 heap: 4796 nest: 13641 copy: 1922 And for java -server: fib: 6375 heap: 4796 nest: 13204 copy: 1891 This is using jdk1.5 on a 3Ghz machine. So the compiler can make a big difference: gcc -O3 takes 17s compared to 10s for whatever you're using. And the -server can make a big difference: it brought the Java time down from 10s to 6s for the fibinocci test. And it's perfectly reasonable to use -server for this kind of thing. The "client" VM is really intended for GUI apps where startup time is to be minimized. Any app where non-GUI performance matters would use -server. So Java is about 3x faster on one test, C++ about 3x faster on another, and they're about the same on two tests. That seems about right to me - I wouldn't say that either one is generally faster than the other - it all depends.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons