I'll post the link before I verify it has what you want, but the Language Shoot-out http://www.bagley.org/~doug/shootout/ has comparisons on multiple criteria (speed, memory usage etc) for many common alrorithms running comparable code written in different languages. Dave
The Scorecard displays a score per language based on custom weightings. The default, which measures only the CPU section of the tests, rates C++ (via the g++ compiler) as 4th with a score of 743. Java was 9th with a score of 703. I'll have to look into where these numbers come from. It looks like a particularly good score for Java.
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Java's performance isn't that bad compared to C++. Remember, the modern Hotspot Engine will compile critical parts of your code to native, too. The runtime optimizations might be even more effective than the static optimizations of a C++ compiler. The biggest problem for *small* programs simply is the heavy startup time of the JVM...
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ran Pleasant
Ranch Hand
Joined: Jan 16, 2003
Posts: 75
posted
0
I've just completed a contract in which I built a prototype of a Java application that displays customer stock trading orders in real-time, data is received through a socket connection to a server. When compared to prototypes written in C++ and Delphi the Java application held up very good even though it had the slowest absolute speed (I do not have the numbers). For all three applications the bottle-neck was the network. In another speed test, the Java prototype is fully completed - the C++ programmer still has plumbing to build. :roll: [ January 17, 2003: Message edited by: Randall Pleasant ]
Ran
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
Originally posted by Paul Wheaton: anybody have some hot web pages comparing the speed of Java and C++?
It depends on what you are doing. Need to process huge byte arrays over and over again. C will kick butt over Java because C has no boundary checking (among other things). Of course, the C program is more likely to contain boundary errors. (A friend of mine had to do this for an image manipulation project he was working on. The Java program took about 4 weeks to run and the C program took about 4 days.) You can write an extremely efficient program in C if you know what you are doing. But that kind of requirement isn't found in a typical business application.
Originally posted by Thomas Paul: It depends on what you are doing. Need to process huge byte arrays over and over again. C will kick butt over Java because C has no boundary checking (among other things). Of course, the C program is more likely to contain boundary errors. (A friend of mine had to do this for an image manipulation project he was working on. The Java program took about 4 weeks to run and the C program took about 4 days.)
That's correct - most people still think that Java is slower because it is interpreted. In fact, when it's slower it's most often because of inbuild security checks other languages are missing. Notice, though, that the modern Hotspot Engine is able to remove some of those checks (as array boundary checks), if its analysis shows that it can't happen.