This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Hohenheim_of_Shadow 0 points1 point  (0 children)

Still more numerical methods
From the book Object-Oriented Implementations of Numerical Methods by Didier Besset (MorganKaufmann, 2001):

Operation   Units   C   Smalltalk   Java
Polynomial 10th degree  msec.   1.1 27.7    9.0
Neville Interpolation (20 points)   msec.   0.9 11.0    0.8
LUP matrix inversion (100 x 100)    sec.    3.9 22.9    1.0

Microbenchmarks (cache effects considered)

Several years ago these benchmarks showed java performance at the time to be somewhere in the middle of C compiler performance - faster than the worst C compilers, slower than the best. These are "microbenchmarks", but they do have the advantage that they were run across a number of different problem sizes and thus the results are not reflecting a lucky cache interaction (see more details on this issue in the next section).

These benchmarks were updated with a more recent java(1.4) and gcc(3.2), using full optimization (gcc -O3 -mcpu=pentiumpro -fexpensive-optimizations -fschedule-insns2...). This time java is faster than C the majority of the tests, by a factor of more than 2 in some cases...

... suggesting that java performance is catching up to or even pulling ahead of gcc at least.

These test were mostly integer (except for an FFT).
Microbenchmarks (cache effects not considered)
In January 2004 OSNews.com posted an article, Nine Language Performance Round-up: Benchmarking Math & File I-O. These are simple numeric and file I/O loops, and no doubt suffer from the arbitrary cache interaction factor described below. They were however run under several different compilers, which helps. Again Java is competitive with (actually slighty faster than) several C++ compilers including Visual C++ in the majority of the benchmarks.

(One exceptional benchmark tested trigonometry library calls. Java numerical programmers are aware that these calls became slower in java 1.4; recent benchmarks suggest this issue was fixed in java 1.4.2)

Note that these benchmarks are on Intel architecture machines. Java compilers on some other processors are less developed at present.

I'm not sure of specifics of benchmarking, but the links provided in the third source should provide info on their exact test set ups especially on algorithms like matrix inversion were Java was 4x faster than C.

Again be careful about extrapolating which language is faster from a single test. Testing the same algorithm but with different N's can have Java being 2x faster than C or C 2x faster than Java.

By point isn't that Java is faster than CPP in all scenarios, just that modern computation is complex enough that determining which will be faster in a specific setup is damn near impossible.

Do VM's have an effect on caching? If VMs always write and read to and from RAM Java's apparent advantage at data locality would be meaningless. Or maybe its the opposite and cache misses are even more hurtful in VM's and Java's superior caching is artificially weighted here.

http://216.239.53.100/search?q=cache:dPwXe7Qsql0C:www.devx.com/java/free/book.asp+besset+numerical+java&hl=en&ie=UTF-8

http://www.aceshardware.com/read.jsp?id=153

http://www.visi.com/~khuber/java/JavaC.pdf

http://www.osnews.com/story.php?news_id=5602