This tutorial explains how to profile java
code running with IBM WebSphere 2.0.
In this document:
<OptItDir> is the directory where
OptimizeIt has been installed. (ex: c:\OptimizeIt\OptimizeIt311D)
<WebSphereDir> is the directory
where WebSphere has been installed (ex: d:\WebSphere)
1) Configuring WebSphere
-
Make sure you configured WebSphere to run Sun's JDK
1.1.7.
-
Edit the file <WebSphereDir>\AppServer\properties
-
Change the line
java.compiler=
to
java.compiler=NONE
-
Change the line
java.classgc=true
to
java.classgc=false
-
Copy the OptimizeIt servlet <OptimizeItDir>\lib\servlet\OptimizeIt.class
to
your servlet directory.
2) Starting the OptimizeIt servlet
-
Invoke the servlet from a web browser.
-
In the HTML page that the servlet provides, change
the port number if necessary.
-
Select the "Disable memory profiler" option if you
only want to focus on CPU usage.
-
Select "Enable OptimizeIt's audit system API" if
your code enables/disables the profiler by using OptimizeIt's audit system
API
-
Press the "Start OptimizeIt Audit System" button
to start the profiler.
Once this operation is done, you should see a message
in your web browser indicating that OptimizeIt's audit system is running.
3) Attaching from OptimizeIt
Now that WebSphere is running with OptimizeIt profiler, you can start OptimizeIt
and attach to the virtual machine.
-
Start OptimizeIt from the Start menu.
-
Close the Edit Settings panel by pressing the OK button.
-
From the Program menu, select Attach.
-
Change the port number and the hostname if necessary.
-
Press the Attach button.
4) Starting OptimizeIt profiler from your Java code
While the OptimizeIt servlet is convenient to start profiling quickly,
you may want to automatically start OptimizeIt profiler with one of your
servlet. That way, you don't have to invoke the OptimizeIt servlet to start
the audit system before testing your servlets.
Starting OptimizeIt profiler can be easily done by using OptimizeIt's
API. OptimizeIt's API is documented in OptimizeIt user manual, chapter
9. The following code demonstrates how to start the profiler from your
servlet:
import intuitive.audit.Audit;
...
static boolean isProfilerStarted = false;
if(!isProfilerStarted) {
/* Start OptimizeIt's profiler */
Audit.start(1470, Audit.PROFILERS_ALWAYS_ENABLED);
isProfilerStarted = true;
}
...
Note: you will need to add <OptItDir>\lib\optit.jar to your
classpath to compile this code
Once OptimizeIt's profiler is running, you can start OptimizeIt and
attach to the servlet engine.
Copyright (c) 1997, 1998, 1999, 2000 Intuitive Systems
Inc. All rights reserved. Specifications subject to change without notice.
OptimizeIt is a trademark of Intuitive Systems, Inc.
Java and all Java-based trademarks and logos are trademarks
or registered trademarks of Sun Microsystems, Inc. All other brand
names and products are trademarks or registered trademarks
of their respective holders.