Free Sun Studio 12, and NetBeans Profiler
Ok ... so what does Sun Studio 12 have to do with NetBeans and the NetBeans Profiler ?
Sun Studio 12 is built on NetBeans.
But, isn't Sun Studio 12 for native languages?
Not exclusively, no.
There are two programs which are part of Sun Studio which I use quite often and find very useful in my Java development. They are called Collector & Analyzer. The Collector collects performance / profiling data into a what is called an experiment file and the Analyzer is a program that reads the experiment file.
Aahh, so the Collector / Analyzer is a competitive product to the NetBeans Profiler? No, not exactly. In fact they compliment each other rather well.
I find the Collector / Analyzer very useful as the first tool in profiling a Java application. By default the Collector samples a running Java application once per second and includes in its profiling data not only user cpu time and system / kernel cpu time, but also lock contention information, (amongst quite a bit more information).
I find the Collector / Analyzer is very good at giving me a very quick high level view of the performance of a Java application. Where I like to use the NetBeans Profiler is once I have found an area, or a couple areas of interest, by using the Collector / Analyzer, I use the NetBeans Profiler to instrument specific methods or call points. Hence, the ability to focus on specific areas of an application is what I find is the NetBeans Profiler's strong point.
Back to the Collector / Analyzer .... A couple additional things it can do ...
Finding contended locks which are performance & scalability "blockers" in a Java application can be a difficult task. But, Sun Studio's Collector / Analyzer makes this task much easier. It can display the amount the time spent waiting to acquire Java locks. Not many profilers can do this and this is one of my favorite features of Collector / Analyzer.
You can also narrow the scope of the profiling run to a specific set of samples. So, if your application goes through a startup phase you can eliminate those samples from the collected data.
In addition to looking at Java methods, you can also get information about how the JVM, i.e. HotSpot, is performing. That's right you can see HotSpot method information too. And, on Solaris Sparc and Solaris x86 (this may be available on Linux too?) you can view the assembly language instructions generated by the JIT compiler for given Java methods. Perhaps not that interesting to most Java developers. But, it can be interesting to those of us who are performance junkies :-)
Have I peaked your interest?
How easy is Collector / Analyzer to setup and configure?
It's as easy as a Sun Studio 12 download, installation, adding the <install dir>/bin directory to your PATH and then starting your Java application with: collect -j on <your old Java command line>. For instance, if you were running a Java command line such as, java -server -jar Java2Demo.jar, you would simply start the collector by issuing a command line of, collect -j on java -server -jar Java2Demo.jar.
Running the collect command will automatically create an experiment file in the directory where you launched the collect command. The file name will be of the form, test.#.er where # begins at the number 1 and increments as needed as you run more collector experiments.
Once you've completed the execution of your Java program, you open the experiment file, the test.#.er file, using the Analyzer which is as easy and typing, analyzer at the command line, (assuming you have the <install path>/bin directory in your PATH). You simply open the experiment file with the Analyzer. From there you can choose to "Filter Data", add additional columns of data to the display to include sys time and lock time, etc.
Perhaps you should try it out for yourself ... A free download is available at: http://developers.sun.com/sunstudio/downloads/index.jsp
There's additional information on how to use Sun Studio 12 and the Collector / Analyzer at:
http://developers.sun.com/sunstudio/
Enjoy!
Powered by ScribeFire.
Posted at 05:01PM Jun 27, 2007 by charliebrown in Java | Comments[2]
Posted by Gregg Sporar on July 06, 2007 at 01:15 PM CDT #
Posted by huntch (aka charlie hunt / charlie brown) on July 06, 2007 at 01:42 PM CDT #