This section demonstrates how to analyze a Java program using a time-based profile. The application program used in this section is the SciMark 2.0 benchmark from the National Institute of Standards and Technology (NIST). Source code for the benchmark can be downloaded from http://math.nist.gov/scimark2/scimark2src.zip. You will need a Java compiler in order to compile the benchmark. CodeAnalyst supports both the Sun Microsystems and IBM versions of the Java Virtual Machine (JVM).
Before starting, ensure that a CodeAnalyst project is open and ready for use. The tutorial section Creating a CodeAnalyst Project demonstrates how to create a new project.
Note: The Java application launcher tool can usually be found in the installation directory for Java.
Note: CodeAnalyst automatically checks for the Java application launcher tool and inserts the –agentlib option into the Launch field. You do not need to enter this option yourself. The agent connects the JVM to CodeAnalyst.
CodeAnalyst starts data collection and launches the Java application program through the Java application launcher tool. When the benchmark program terminates and data collection is finished, CodeAnalyst displays results in three tabbed panels—System Data, System Graph and Processes. The System Data table shows a module-by-module breakdown of timer samples. Each timer sample represents approximately 1 millisecond of execution time (when using the default timer interval of 1 millisecond).
Performance data for this example was collected on a dual-core AMD Athlon™ 64 processor. The benchmark program is single-threaded and keeps only one core busy. The other core is available for other processes in the system. In this case, the System Data table attributes roughly 98% of the timer samples to the application program (jnt.scimark2.commandline).
Note: Due to scheduling decisions made by the operating system, the application program may execute on either core and may even migrate between cores.
The System Graph shows the module-by-module breakdown of timer samples in the form of a bar chart.
The Processes table displays the distribution of timer samples across the software processes that were active during data collection. CodeAnalyst monitors activity on a system-wide basis. It collects data on any active software component—application programs, libraries, device drivers or kernel modules. Time spent idle is ascribed to the system-idle process.
CodeAnalyst displays a new tabbed panel containing the annotated assembly code for the function transform_internal. The number of timer samples for each instruction is shown.
Note: CodeAnalyst Linux® does not provide source view for Java application. CodeAnalyst monitors the execution of just-in-time (JIT) compiled code.
You may also use CodeAnalyst to collect data on a Java program (or any other application program) that is launched from a command line. This is sometimes more convenient than launching the application from within CodeAnalyst.
At the shell command line, enter the following command to start the benchmark program:
java -agentpath:/opt/CodeAnalyst//bin/libCAJVMTIA64.so jnt.scimark2.commandline
You must use the CodeAnalyst profiling agent that is appropriate for the JVM. After 40 seconds has expired, CodeAnalyst stops data collection and displays results in its workspace.
Some versions of the JVM have deprecated the use of the -XrunCAJVMPIA option. Java -X options are non-standard and are subject to change without notice.