Suitability (of Java)

Tushar Teredesai tushar at
Fri Apr 2 16:51:57 PST 2004

Don Smith wrote:

> Tushar Teredesai wrote:
>> Do you have any references to any recent benchmarks on the speed 
>> comparison?
>> Especially with JIT, the performance of C++ and Java code is 
>> comparable, especially when the new programs are loaded in an already 
>> existing JVM. And the productivity is higher (less bugs).
> Try these. Using JDK 1.3.1 (admittedly old) on my 200Mhz x86 system 
> (with a loop of only 100,000,000 instead of 1G) I get 16 seconds for 
> the C++ code and 36 seconds for Java (after the JVM is loaded).
> Can someone try this with the latest JDK to see if this still holds?
> JIT would probably solve this problem. (I have to use the older JDK 
> because that's what my main customer is using.)

 $ c++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: ../gcc-3.3.3/configure --prefix=/usr 
--enable-languages=c,c++,f77,java,objc --enable-threads=posix 
--enable-__cxa_atexit --enable-clocale=gnu --with-system-zlib 
--enable-shared --without-x
Thread model: posix
gcc version 3.3.3

 $ java -version
java version "1.4.2-internal"
Java(TM) 2 Runtime Environment, Standard Edition (build 
Java HotSpot(TM) Client VM (build 1.4.2-internal-tt-1080196214, mixed mode)

 $ c++ -o Increment Increment.cpp

 $ javac

 $ time ./Increment
Evens: 500000000 Odds: 500000000
Time: 17.191453
real    0m17.231s
user    0m17.140s
sys     0m0.000s

 $ time java Increment
Evens: 500000000 Odds: 500000000
Time: 10.959
real    0m11.258s
user    0m11.130s
sys     0m0.010s

Tushar Teredesai

More information about the hlfs-dev mailing list