M
Mark Sizzler
Are there any performance benchmarks between c++ and java code for standard algorithms?
For example the "sieve of the erastothenes"?
Mark
For example the "sieve of the erastothenes"?
Mark
Are there any performance benchmarks between c++ [sic] and java [sic] code for standard algorithms?
For example the "sieve of the erastothenes"?
Possibly, but they are useless comparison for most people. MachineMark said:Are there any performance benchmarks between c++ and java code for standard algorithms?
For example the "sieve of the erastothenes"?
Mark
Never heard of it. I *have* heard of something called the Sieve of
Eratosthenes that identifies prime numbers, but since the supply of
primes is infinite the running time is O(1/0) and the constant factors
are unimportant. All programming languages take the same amount of time
to complete an infinite loop.
Are there any performance benchmarks between c++ and java code for standard algorithms?
For example the "sieve of the erastothenes"?
Lew said:Even when Java or C# are somewhat slower, it's not by much any more
(for most things), and as the cited article points out, the advantages
(e.g., maintainability, correctness, portability and not having to
manage memory explicitly (up to 30% of a C++ program according to the
experts)) outweigh most performance disadvantages.
Are there any performance benchmarks between c++ and java code for
standard algorithms?
For example the "sieve of the erastothenes"?
Mark
Not the sieve in this instance, but you'll find some interesting answers
at the computer language benchmark game:
http://shootout.alioth.debian.org/
I was pleased to see that this has recently (11 Nov 2008) been updated,
so the results are quite current.
Are there any performance benchmarks between c++ andjavacode for standard algorithms?
For example the "sieve of the erastothenes"?
Mark
Mark said:Are there any performance benchmarks between c++ and java code for standard algorithms?
For example the "sieve of the erastothenes"?
Mark
Search the web with your words "performance benchmark java c++" and get
e.g.
http://www.idiom.com/~zilla/Computer/javaCbenchmark.html
http://kano.net/javabench/
and many more.
As a rule of thumb one can assume a factor of 1.5 comparing compiled vs.
"interpreted bytecode".
In fact, it depends on the implementation and the concrete problem.
Imaging a chess program: using Objects (new..) is killing performance
here, but that's (chessprog) a very special task..
Norbert said:Search the web with your words "performance benchmark java c++" and get
e.g. <http://www.idiom.com/~zilla/Computer/javaCbenchmark.html> <http://kano.net/javabench/>
and many more.
As a rule of thumb one can assume a factor of 1.5 comparing compiled vs.
"interpreted bytecode".
In fact, it depends on the implementation and the concrete problem.
Imaging a chess program: using Objects (new..) is killing performance
here, but that's (chessprog) a very special task..
Lew said:Is it?
I know.Allocation for objects in Java is blazingly fast, on the order of
10-12 machine instructions, much faster than most other languages.
That's because Java allocation involves mostly just incrementing a
pointer to heap.
No doubt about that. But nobody asked it, did one?Garbage collection does take time, less for short-lived object than
for Methuselahs, but people tend to overestimate the impact relative
to real-world programs in non-managed-memory environments. That's
because without managed memory, the program itself must manage
deallocation, which results in bugs and takes its own overhead. (I've
read that 30-40% of code in a non-managed-memory language supports
memory management.)
Really, do they? That implies that every Java-Application that has notAs for "interpreted bytecode" overhead, that depends on how much the
bytecode actually is interpreted. In practice, real-world Java
programs have their performance-intensive sections compiled to native
machine code, taking advantage of dynamic optimization not available
to statically-compiled languages.
I was on a project in the early 1990s that interpreted HP Business
BASIC on a '386 PC with performance equivalent to HP's own compiled
version of that language on their own mainframe. That interpreter
didn't even have an equivalent to Java's Hotspot compiler; it was just
efficient.
In some cases Java runs within 1-2% of the speed equivalent compiled C
or C++ code, and in others it runs even faster. Micro-benchmarks I've
run typically agree with Norbert's rule of thumb that the Java goes
runs about 30-50% slower for CPU-bound, single-threaded code, but
benchmarks are pretty blunt tools. In the real world the run-time
performance is so close as to be overshadowed by other considerations,
for most applications.
Regardless, one must avoid spreading urban legends about the overhead
of memory allocation and garbage collection, or "interpreted
bytecode", when discussing Java run-time performance.
Norbert said:Really, do they?
That implies that every Java-Application that has not
compiled it's [sic] performance-intensive stuff is not a real-world Java-App..
Compiling java-Code should only the be the last line of defence.
As a rule of thumb one can assume a factor of 1.5 comparing compiled vs.
"interpreted bytecode".
Norbert said:Yes, it is. I'm talking about creating millions (!) of objects
Really, do they?
Yes.
That implies that every Java-Application that has not
compiled it's performance-intensive stuff is not a real-world Java-App..
As a rule of thumb one can assume a factor of 1.5 comparing compiled vs.
"interpreted bytecode".
But nobody has used interpreted byte code in Java for years, except in
cell phones where RAM and batter power is limited. On the desktop it is
now hotspotted (Sun JVM) or native machine code (Jet).
Tom Anderson said:My understanding is that in the Sun JVM, bytecode is still interpreted
before it gets hotspotted.
Roedy said:As a rule of thumb one can assume a factor of 1.5 comparing compiled vs.
"interpreted bytecode".
But nobody has used interpreted byte code in Java for years, except in
cell phones where RAM and batter power is limited. [...]
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.