Need for speed: Java overtakes C++?

Someone did an experiment here about the comparison of java and c++ performance.

In this experiment, I will test the wall clock time of computing a multiplication of a 2000 by 2000 matrix  with a 2000 vector.

Java is much faster than plain g++ compiler, comparable with O2 optimization, and only tiny slower than O3.

=======Result=========

+ javac jmatrix.java
+ java jmatrix
java allsum=1.8658666E16
real 15.03
user 17.30
sys 8.69
+ g++ cmatrix.cpp -o cmatrix
+ ./cmatrix
c++ allsum=1.86587e+16
real 57.28
user 57.25
sys 0.02
+ g++ -O2 cmatrix.cpp -o cmatrix2
+ ./cmatrix2
c++ allsum=1.86587e+16
real 15.34
user 15.33
sys 0.02
+ g++ -O3 cmatrix.cpp -o cmatrix3
+ ./cmatrix3
c++ allsum=1.86587e+16
real 14.86
user 14.85
sys 0.02

======Specification of the machine===============

ubuntu 10.04 64 bit Linux 2.6.32-37-generic

g++ (Ubuntu 4.4.3-4ubuntu5) 4.4.3

OpenJDK Runtime Environment (IcedTea6 1.9.10) (6b20-1.9.10-0ubuntu1~10.04.2)
OpenJDK 64-Bit Server VM (build 19.0-b09, mixed mode)

6 CPU

8G memory

This entry was posted in 未分类. Bookmark the permalink.

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Connecting to %s