File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Performance and the fly likes numerical performance java vs C Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "numerical performance java vs C" Watch "numerical performance java vs C" New topic

numerical performance java vs C

james mercer

Joined: Jun 01, 2006
Posts: 2
I've been testing Java versus C after seeing sites that mention Java is closs to the performance of C for numerical computing. In order to use a standard code that is available in C and java, I've tried scimark2 ( However, the results are not as simple as the 'java is just as fast as C' articles suggest.

All java results are with the compiled scimark java benchmark. The C results are from using gcc. All results are the composite score.

On a PA-Risc system running HPUX11i and java1.4/gcc2.95, scimark2 produces:
C: 282
Java: 262
and scimark2 -large gives:
C: 70
Java: 55
this comparison agrees with expectation and also shows an enormous penalty for the -large problem which may exceed the cache of many processors (the PA-risc 8700 with 2.25MB L1 cache, no L2)
I tried java -server but the differences to the above numbers were trivial.
With java1.5 on the pa-risc based system scimark2 produced 150MFlops

On a 2.8GHz Pentium4 running Win2000 and java1.5/gcc2.95, scimark2 gives:
C: 300
Java: 180
and scimark2 -large gives:
C: 200
Java: 160

So, I have two questions: is there a performance difference between java1.4 and java1.5 that would explain the huge slowdown on the pa-risc system?
Secondly, while the pa-risc system results for java1.4 and C compare well, the C versus java on the Wintel system doesn't compare well at all. For that matter, the java1.5 on the pa-risc system is very poor compared to C. Are there extra performance issues or settings with java1.5 to alter this?

Any info or suggestions would be appreciated.

Mahadevan Gorti SS

Joined: Jan 31, 2006
Posts: 18
When you applied -server flag for JVM, did you run the benchmark for some warmup time --so that JVM can findout hotspots properly and do necessary optimizations
james mercer

Joined: Jun 01, 2006
Posts: 2
Thanks for the suggestion. I was able to do more testing and found the java results more inline with expectations.

On the Wintel P4/2.8GHz with Java1.5 scimark2 produced:
C ~300
Java ~180
Java -server ~430
Thus, the default -client on Windows (PC not server) hampered the performance and using the -server option now produced significantly better results than C. This is very good. Further testing with the -large version of scimark2 produced similar results for C, java and java -server.

However, all testing with java1.5 on the PA-risc system showed it to be slower than the java1.4 version. I used a serious of optimization options from the Sun performance document and they only added a few percent extra. I'm confused by the pa-risc results, but I know that the pa-risc is now end of life. Therefore, spending too much more time on the pa-risc might not be worth while.

Still, if anyone knows how to increase the performance of java on the pa-risc, please, let me know - a pa-risc system runs our core java application.

Mr. C Lamont Gilbert
Ranch Hand

Joined: Oct 05, 2001
Posts: 1170

Point of correction, you cant compare Java to C. Java is a language and an environment. C is only a language. If you are comparing performance then you are comparing So-and-So's JVM performance, vs. So-and-So's C compiler code optimization performance.

This is not Java vs. C. The JVM you are running may well have been written in C.
I agree. Here's the link:
subject: numerical performance java vs C
It's not a secret anymore!