Java Performance
One of the most widespread
misconceptions about Java is that it is slow. Today, with the
existence of highly optimized JITs (Just in Time Compilers), this
is not longer true on most platforms. Most Java applications run
with as little as 20-40% overhead compared to traditional
optimized C++ code. And in multithreaded applications, as e.g.
applications relying heavily on I/O, no measurable performance
difference exists between Java and C++, due to Java's excellent
built in support for multithreading.
With the advent of more
sophisticated dynamic compiling in the upcoming HotSpot runtime,
Java programs may actually be able to run quicker than C++ code,
due to the fact that dynamic recompiling (which is what a JIT is
really about) can morph the program to match the actual code
dispatches and the underlying runtime in a way that isn't
possible with static compilers, which traditional languages like
C++ rely on. (One of the advantages whith dynamic compiling is
that the compiler can choose to dynamically inline code, due to
knowledge of frequent code dispatch paths - a feature that isn't
possible in static compiling of object oriented code to the same
extent, as the compiler then doesn't know if a method may
actually be inherited in another part of the application.)
Part of the performance of Java
is also its robustness and built in security, making it much
easier to write safe and stable applications than would be
possible in C++. Java's dynamic linking and bytecode-format,
which retains method names and signatures in the compiled code,
makes it easy to maintain the code, and to distribute it on
networks - a fact that is well known to the internet community
today. With the upcoming
Embedded Javaplatform, Java will also enter consumer
electronics, giving the "Write once - run anywhere" a
new dimension.
Of course there are
some benchmarks for comparing different Java platforms, such as
CaffeineMark and
ByteMark,
and some nice links on
Java Optimization.
A nice tool for graphical profiling is
HyperProf.