Skip to Main Content

Java HotSpot Virtual Machine

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JDK Performance tests...interesting results...

843811Mar 22 2002 — edited Oct 11 2002
In an effort to try and eek out as much performance from a Java application as possible, I decided to conduct a little experiment on various JDKs on Sun Solaris 8. What I found was very interesting, and I thought I would share this with the group.


I tested 2 main areas, Class Generation and Number Crunching. I wrote a little application that does a series of tests a multitude of times, timming each one and the overall, and reporting the time. I tested the 1.2.2, 1.3.1, and 1.4.0 (both 32-bit and 64-bit). Here is what I found...


Class Generation
-------------------------
There has been this argument at the water cooler for sometime that cloning an object is faster than creating a new one. I created two tests...one that creates 1000 objects 10000 times using the constructor, the other creates a single "default" object, then clones 1000 objects 10000 times using the Object.clone() method. The two methods are identical, except the cloning requres a try/catch block around the clone() call and it creates the default class in it's constructor (both use a home-grown class called DummyClass, which implements java.lang.Cloneable). All classes where compiled with the JDK 1.3.1.

What I found is that cloning was about 26.16% <b>slower<b> than actually creating the object, finishing on average in 295822.133ms vs. 218438.8ms. The slowest performers overall was the JDK 1.4.1, 64-bit, and the fastest was the 1.3.1 with a -server flag. Here is the chart:
JDK                             Inst.                Clone
1.3.1                           232874.667           280938.333
1.3.1, -server                  190872.000           252238.000
1.4.0                           206234.333           340177.667
1.4.0 64-bit                    231025.333           302989.333
1.4.0 64-bit, -server           231188.667           302767.333
JDK Performance
--------------------------
In this test I pitted the 1.2.2, 1.3.1, and 1.4.0 against one another. This uses the same Class Generation test as above, plus a Fibinochi number test to perform a calculation intensive test. I also tested the code compiled in different means. Here is the chart (it is a link, because the chart is pretty large):
http://www.phuongphoto.com/jdk_tests/

Ironically, the 1.2.2 outperformed the other JDK tests hands down. The only explination I have is that the 1.2.2 is running in native threads, and I cannot figure out how to turn that off the 1.2.2, nor turn it on the other JDK versions.

Another interesting note is that the 64-bit 1.4.0 was out performed in class creation, but did pretty well in raw calculations, almost matching the 1.2.2, even with it's native threads. It also seemed to perform ever-so-slightly better without the -server switch, but all-in-all it didn't make much of a difference. The other JDKs all performed much better with the -server flag on.



I am interested to find what everyone else thinks about this. In particular, can anyone instruct me on how to turn on native threads in the 1.3.1 and 1.4.0 so we can level the playing field? Also, I'd be interested to see some other numbers, if anyone else has any.


Mike Bauer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 8 2002
Added on Mar 22 2002
3 comments
427 views