Java 1.2 introduced an experimental profiling interface, called JVMPI (Java Virtual Machine Profiler Interface). The interface comes with a sample profiling agent, called hprof. Any VM that supports JVMPI should be also able to run hprof.
This agent creates profile data files which can be interpreted after the program terminates. However, the format of the files is still evolving. This version of HPjmeter supports only the formats compatible with JavaSoft reference implementations JDK-1.2.1-A or JDK-1.3.0-C for Solaris(TM) or Windows(R) NT(R)), and in particular:
-classic to select the Classic VM)
To run your application with profiling use the following command:
java ... -Xrunhprof:<options> ApplicationClassName
|
To profile your applet, use:
appletviewer ... -J-Xrunhprof:<options> URL
|
We have found the following hprof options useful:
cpu=samples,thread=y,depth=10,cutoff=0,format=a
heap=all,cpu=samples,thread=y,depth=10,cutoff=0,format=a
To see the complete list of available options, use
java ... -Xrunhprof:help
|
The options which affect the collection of profile data supported in this version of HPjmeter are described below:
heap=dump|sites|all
cpu=samples|times|old
hprof are CPU virtual times.
This is the time when a thread is runnable, but not necessarily running.
cpu=samples uses sampling as the collecting technique,
while the two remaining options use tracing (with reduction).
The hprof implementation for HP-UX 11.0
is an exception. Unless sampling is used, the collected
times are real CPU times rather than virtual CPU times.
cpu=old outputs inclusive method times,
while the two other options output exclusive times.
HPjmeter can derive inclusive
times from the exclusive times, but only by using estimation.
cpu=old cannot produce profiling data
separately for each thread.
Collecting heap data can be very intrusive for time metrics,
so we recommend that you do not measure the method times and heap usage at the
same time.
However, specifying heap=sites and
cpu=samples|times for the same run makes sense
if you'd like to find
the allocation sites in the call graph.
thread=y|n
thread=n).
If you do not use cpu=old, we suggest that you always
specify thread=y.
With the thread identification in the profile file, HPjmeter
can calculate the thread profile data for the whole application.
depth=<size>
cutoff=<value>
format=a
Trademark Acknowledgement
Solaris is a trademark of Sun Microsystems, Inc.
in the U.S. and other countries.
Windows NT is a U.S. registered trademark of Microsoft Corporation.