Performance Profiling Java Applications
Using the NetBeans
Profiler
NetBeans IDE 6.0 includes a powerful profiling tool that can provide
important information about the runtime behavior of your application.
The NetBeans profiling tools easily enable you to monitor thread
states, CPU performance, and memory usage of your application from
within the IDE, and imposes relatively low overhead.
In this hands-on lab, in the first exercise, you are going to learn how
to profile only part of an application (instead of the entire
application or entire classes used by the application) using root
method selection scheme. In the second exercise, you will learn
how to use profiling points for breakpoint-like profiling. In the
third and fourth exercises, you are going to learn how to capture
thread information and CPU performance respectively.
Expected duration: 120 minutes
(excluding homework)
Software Needed
Before you begin, you need to install the following software on your
computer.
- Java Standard Development Kit (JDK™) version 5.0 (download)
or 6.0 (download)
- If you are installing JDK 6.0
- Select JDK 6 Update x
from the download page
- If you are installing JDK 5.0
- Select JDK 5 Update x
from the download page
- NetBeans IDE 6.0 (download)
or later version
- Download either "Web &
Java EE" or "All"
bundles.
- When you install NetBeans IDE, it will ask you which JDK
you want to use. Select either JDK 5.0 or JDK 6.0.
- 5114_nbprofilerperformance.zip (download)
- The zip file contains this document and the lab contents
- Download it and unzip in a directory of your choice.
Operating Systems/platforms you can use
- Windows
- Solaris x86, Solaris Sparc
- Linux
- Mac OS
Change Log
Things to do (by Authors)
- Add more explanation to the exercises
Lab Exercises
Exercise 0: Perform JDK calibration
In this exercise, you will perform
calibration against the JDK running on your system. The
calibration is
required in order to perform profiling. It does not affect in any way
the
behavior of your Java applications. This needs to be done only
once.
Note: Instrumenting the bytecode of the profiled application imposes
some overhead. To guarantee the high accuracy of profiling results,
NetBeans Profiler needs to collect calibration data in order to "factor
out" the time spent in code instrumentation. You need to run the
calibration process for each JDK you will use for profiling. The
calibration data for each JDK is saved in the
.nbprofile directory in your
home directory. You are prompted to run the
calibration the first time you invoke NetBeans Profiler. You are also
prompted if the calibration data for the local machine and JVM is
unavailable.
(0.1)
Run profiler calibration
1. Select Profile from
top-level menu and select Advanced
Commands->Run Profiler Calibration. (Figure-0.20 below)

Figure-0.20: Run Profiler Calibration
- Select JDK 1.6 (Default)
(Figure-0.21 below)
- Click OK.

Figure-0.21: Select Java Platform to calibrate
- Observe that the Information dialog
box indicating that the Calibration was successful.
- Click OK to close the
dialog box.

Figure-0.22: Information dialog box
Exercise 1: Perform profiling on
"Java2D" sample application
One of the benefits of using NetBeans
profiler is that it lets you profile only the parts of your
application that are really of interest. You can, if you want,
profile the entire application, but that can have a big impact on
performance.
In this exercise, you are going to
profile the entire application and see the performance impact of
it. Then you are going to learn how to profile only part of the
application by the scheme of root method selection, thus limit the
overhead imposed by the
profiler to only those parts of an application that you suspect have a
performance problem.
(1.1)
Open, build, and run "Java2D" sample application (without profiling)
1. Open Java2D
NetBeans project.
- Select File->Open Project (Ctrl+Shift+O).
(Figure-1.11 below)

Figure-1.11: Open a project
- The Open Project dialog
box appears.
- Browse down to and expand <LAB_UNZIPPED_DIRECTORY>/nbprofilerperformance/samples
directory.
- If you unzipped the 5114_nbprofilerperformance.zip
file under C:\handsonlabs
directory under Windows, the directory to which you want
to browse down should be C:\handsonlabs\nbprofilerperformance\samples.
- If you unzipped the 5114_nbprofilerperformance.zip
file under $HOME/handsonlabs
directory under Solaris/Linux, the directory to which you want
to browse down should be $HOME/handsonlabs/nbprofilerperformance/samples.
- Select Java2D.
- Click Open Project.
(Figure-1.12 below)

Figure-1.12: Open Java2D project
- Observe that the Java2D
project node appears under Projects tab
window.
2. Build and run the application.
- Right click Java2D project
node and select Run.
- Observe that the Java 2D(TM) Demo application appears.
- Click Arcs_Curves tab
window.
- Click Clipping tab
window.
- Click Colors tab window.
- Observe that for Colors,
there is a statistical data "frames per second", Colors Rotator3D 33.1 fps in this
figure below, being displayed in the lower right corner. (Figure-3.13
below)

Figure-1.13: Run various Java2D features
- Select File and Exit to close the Java 2D(TM) Demo
application. (Figure-1.14 below)

Figure-1.14: Exit the application
return to top of the exercise
(1.2)
Profile the
entire application (just to see how slow it gets)
1. Profile Java2D sample application.
- Right click Java2D and
select Profile. (Figure-1.21
below)

Figure-1.21: Start Profiling Java2D application
- Observe that the Enable
Profiling of Java2D dialog box appears.
- Click OK. (Figure-1.22 below)

Figure-1.22: One time change of the build script of the project
confirmation
- Observe that the Profile Java2D
dialog box appears.
- Select CPU on the left
(if it has not been selected already).
- Select Entire application.
- For Filter drop-down
menu, select Profile all classes.
- For the Use Defined Profiling
Points check box, uncheck it (if it has been checked before).
- Observe that the Overhead
field indicates how much overhead is
incurred by the profiling.
- Click Run. (Figure-1.23
below)

Figure-1.23: Analyze Performance
- Observe that the Java 2D(TM) Demo application GUI appears.
- Click Arcs_Curves tab
window.
- Click Clipping tab
window.
- Click Colors tab window.
- Observe that for Colors,
the "frames per second" is significantly lower, 19.3 fps in the figure below, than
without profiling. This is the typical problem of profiling
the entire application. The profiling adds quite a bit of
overhead. (Figure-1.24 below)

Figure-1.24: Result of running the entire application
2. Observe the number of methods that are being profiled.
- Observe that the Profiler tab
window gets displayed in the NetBeans IDE.
- Scroll down the Profile window
to see the Basic Telemetry
section.
- Observe that the number of methods that are instrumented are over
18,000. (Figure-1.25 below) This is because it is profiling every
single method of every class that is being used by the
application. Note that this is a small application. With a
real-world application that number could be much larger.

Figure-1.25: Number of methods being profiled (instrumented)
3. Display the Live Results.
- Click Live Results icon
on the left of the NetBeans IDE.
- Observe the methods that are being
profiled are being displayed on the right of the NetBeans IDE.
(Figure-1.26 below)
- Scroll through it to show how many rows it has. The other
problem with profiling everything is that you end up with too
much information to wade through in order to find the cause of
performance problems.

Figure-1.26: Live Results
4. Stop profiling.
- Click Stop button (red
square with a white x inside). (Figure-1.27 below) This will stop
the profiling.

Figure-1.27: Stop profiling the entire application
return to top of the exercise
(1.3)
Profile part of the application through "Root Method"
Since you now know the perils of profiling an entire application, in
this step, you are going to take a different approach. What some
profiling tools force you to do is define filters of package
and/or class names for what should or should not be instrumented by the
profiler. The NetBeans Profiler supports filters, but it also has a
more powerful feature: root methods.
1. Open Rotator3D.java.
- Expand Java2D->Source
Packages->java2d.demos.Colors.
- Double click Rotator3D.java
to open it in the editor window.
- Click render(int w, int h,
Graphics2D g2) method in the Navigator
pane in the low and left side of the IDE to display the
method in the editor window. (Or you can go to the method
directly in the editor window - line number 135.)

Figure-1.31: Find render(..) method
2. Add render(...) method as a root method for profiling
- Right click the line of the
render(int w, int h, ...) in the editor window and select Profiling->Add As Profiling Root Method.
(Figure-1.32 below)

Figure-1.32: Add render(..) method as a root method for profiling
- Observe that the Select Setting
Configuration dialog box appears.
- Select Analyze Performance.
It should have been select as a default. (Figure-1.33 below)
- Click OK.

Figure-1.33: Select Settings Configuration
3. Add step(..) as the second root method for profiling.
- Right click the step(int w, int
h) and select Profiling->Add
As Profiling Root Method. (Figure-1.34 below)

Figure-1.34: Add step(..) ad a root method
- Observe that the Select Setting
Configuration dialog box appears.
- Select Analyze Performance.
(Figure-1.35 below)
- Click OK.

Figure-1.35: Select Settings Configuration
4. Run the application with Profiling
- Right click Java2D project
node and select Profile.
(Figure-1.36 below)

Figure-1.36: Profile the application with 2 root methods
- Observe that the Profile Java2D
dialog box appears.
- Select CPU on the left
(if it has not been selected already).
- Select Part of the application.
- (Optional step) Click edit...
link. (Figure-1.37 below) This is to verify that you added render(..)
and step(..) methods as profiling root methods correctly.

Figure-1.37: Part of application is profiled
- (Optional step) Click OK.

Figure-1.38: Observe that render(..) and step(..) methods are defined
as root methods
- Click Run. (Figure-1.39
below) This will start the profiling.

Figure-1.39: Start the profiling
5. Run various part of the Java2D application.
- Click Arcs_Curves tab
window.
- Click Clipping tab
window.
- Click Composites tab
window. (Figure-1.40 below)

Figure-1.40: Run various part of the Java2D application
6. Run Colors of the application.
- Click Colors tab
window. (Figure-1.41 below)

Figure-1.41: Run Colors
7. Observe the number of methods that are being profiled.
- Scroll down the profiler pane to see the Basic Telemetry section.
- Observe that the number of methods that were instrumented is much
smaller, 592 methods in this example. (Figure-1.42 below)

Figure-1.42: Number of instrumented methods under 2 root methods
8. Take the snapshot.
- In the profiler pane, click Take
Snapshot icon.
- Observe that the Call Tree of
the two methods, render(..)
and step(..) methods, are
being displayed
in the right side of the IDE. (Figure-1.43 below)

Figure-1.43: Take the Snapshot of the profiling
return to top of the exercise
Summary
In this exercise, you learned how to
profile only part of an application by designating methods of an
application as root methods.
return to
the top
Exercise 2: Profiling
Points
You can place profiling points in your source code to more precisely
control the collection of profiling results, similar to debugger
breakpoints.
You can use profiling points to automatically trigger actions when
certain conditions are met, such as execution of a line of code, time
elapsed, or memory used. Profiling points can trigger heap dumps, the
resetting of results collected, the running of a load generator script,
and the taking of a results snapshot.
For example, there are situations where you want to control
the features the profiler provides at specific points in your
application and/or at specific points in time. Profiling points
allow you to do that. So they are very similar to breakpoints in
a debugger. To take just one example, you can set a profiling
point to clear the profiler's buffer of collected results at the
beginning of a method and then set a second profiling point at the end
of the method to save off the results that accumulated during the
execution of that method.
- Build and run "Anagram Game" sample application
- Insert profiling points
- Profile the application with profiling points
(2.1)
Build and run
"Anagram Game" sample application
1. Create a new NetBeans project from Sample applications (that are
being shipped with NetBeans IDE).
- Select File->New Project.
- Expand Samples and
select Java under Categories and select Anagram Game under Projects. (Figure-2.11 below)
- Click Next.

Figure-2.11: Create Anagram Game project
- Observe that Name and Location
pane of the New Anagram Game
dialog box appears.
- Observe that the Project Name
field has been already set as AnagramGame
by
the IDE.
- Click Finish. (Figure-2.12 below)

Figure-2.12: Name and Location
return to top of the exercise
(2.2)
Insert profiling points
1. Insert a profiling point at the start of the constructor of the
Anagram class.
- Move cursor to the line number 55 - initComponent(); - and right click
it.
- Select Profiling and
then select Insert Profiling Point.
(Figure-2.21 below)

Figure-2.21: Insert Profiling Point
- Observe that the New Profiling
Point dialog box appears.
- Select Reset Results
under Profiling point type:
section on the right side of the dialog box if it has not been selected
already. (Figure-2.22 below) The Reset Results is selected as a
default by the IDE. By selecting it, you are basically telling
the profiler to reset its buffer of collected results when it gets to
the beginning line of the method.

Figure-2.22: Select Reset Results
- Observe that the Customize
Properties pane appears.
- Click Finish. (Figure-2.23 below)

Figure-2.23: Customize Properties of the profiling point
2. Insert a profiling point at the end of the constructor of the
Anagram class.
- Move cursor to the line number 64 - starting with (screenSize.height - and right
click it.
- Select Profiling and
then select Insert Profiling Point.
(Figure-2.24 below)

Figure-2.24: Insert Profiling point
- Observe that the New Profiling
Point dialog box appears.
- Select Take Snapshot
under Profiling point type:
section on the right side of the dialog box. (Figure-2.25 below) This
second profiling point specifies that the profiler should take a
snapshot at the end of this last line in the constructor.

Figure-2.25: Select Take Snapshot on the profiling point
- Observe that the Customize
Properties pane appears.
- Click Finish. (Figure-2.26 below)

Figure-2.26: Customize Properties of the profiling point
- If the Profiling Points window
is not open at the bottom of the IDE, select Window > Profiling >
Profiling Points in order to display it.
- Observe that the Profiling
Points tab window now displays the two
profiling points you have created. (Figure-2.27 below)

Figure-2.27: Profiling Points tab window
return to top of the exercise
(2.3)
Profile
"Anagram Game" sample application (with two profiling points)
1. Profile the application.
- Right click AnagramGame project
node and select Profile.
(Figure-2.31 below)

Figure-2.31: Profile the application
- Observe that the Enable
Profiling of AnagramGame dialog appears. (Figure-2.32
below) This appears only once the first time the project gets
profiled.
- Click OK.

Figure-2.32: Enable Profiling of AnagaramGame
- Select CPU on the left
(if it has not been selected already).
- Observe that the Analyze
Performance pane appears.
- Select the Entire application.
- For the Filter, select Profile only project classes.
(Figure-2.33 below)

Figure-2.33: Analyze Performance dialog box
2. Observe that the AnagramGame application GUI appears. (Figure-2.24
below)

Figure-2.24: AnagramGame GUI
3. See the profiling result.
- Make sure the Profiling Points
tab window is selected in the lower part of the IDE.
- Click report link of
the 2nd profiling point. (Figure-2.25
below) Since this profiling point has a snapshot of results
available, we can go directly to those results.

Figure-2.25: Display the report
- Observe that the Take Snapshot at Anagrams:64 page appears. Note
that there was only one hit.
- Click open snapshot link.
(Figure-2.26 below)

Figure-2.26: Take Snapshot at Anagrams:64 page
- Observe that the duration of time that is spent. (Figure-2.27
below)

Figure-2.27: Result
4. Display the source code.
- Right click the line of
com.toy.anagram.ui.Anagrams.initComponents() and select Go to Source. (Figure-2.28 below)

Figure-2.28: Go to Source
- Observe that the IDE displays the initComponents(). Note that is
the method that gets invoked within the Anagrams() constructor method.
(Figure-2.29 below)

Figure-2.29: Display the source code
5. Stop the profiling.
- Click Stop profiling icon (red box with white-colored x inside)
return to top of the exercise
Summary
In this exercise, you learned how
to use profiling points.
return to
the top
Exercise 3: Monitor Threads Status
(3.1)
Build and run
"MonitorThreads" sample application and observe the undesirable
behavior
1. Open
MonitorThreads
NetBeans project.
- Select File->Open Project (Ctrl+Shift+O).
- The Open Project dialog
box appears.
- Browse down to and expand <LAB_UNZIPPED_DIRECTORY>/nbprofilerperformance/samples
directory.
- If you unzipped the 5114_nbprofilerperformance.zip
file under C:\handsonlabs
directory under Windows, the directory to which you want
to browse down should be C:\handsonlabs\nbprofilerperformance\samples.
- If you unzipped the 5114_nbprofilerperformance.zip
file under $HOME/handsonlabs
directory under Solaris/Linux, the directory to which you want
to browse down should be $HOME/handsonlabs/nbprofilerperformance/samples.
- Select MonitorThreads.
- Click Open Project.
(Figure-1.12 below)
- Observe that the MonitorThreads
project node appears under Projects tab
window.
2. Build and run the application.
- Right click MonitorThreads project
node and select Run.
- Observe that GUI of the application appears. (Figure-3.11
below) Note that the Seconds
Before Notifications is set to 30 seconds.
3. Observe the undesirable behavior of the application
- Click Start button.
- Observe that the it does not redraw correctly. (Figure-3.11 below)

Figure-3.11: Start button does not work as expected
- Click Exit button.
- Observe that it does not respond at all. (Figure-3.12 below)

Figure-3.12: The Exit button does not work as expected.
- Obstruct the view of the window by putting another window on top
of part of it. When you move the other window away, notice that the
sample application does not redraw its window correctly as shown in
Figure-3.13 below.

Figure-3.13: Obstructed view of the window
4. Even notification occurred in 30 seconds.
- After the 30 seconds, observe that the message box will be
displayed, as shown in Figure-3.14 below.
- Click the OK button on the message box.

Figure-3.14: Notification message box
return to top of the exercise
(3.2)
Profile the application and display the thread information
1. Run the application with profiling.
- Right click MonitorThreads project
node and select Profile.
(Figure-3.21 below)

Figure-3.21: Profile the application
- Observe that the Enable Profiling of MonitorThreads message
box appears.
- Click OK. (Figure-3.22 below)

Figure-3.22: Enable Profiling of MonitorThreads
- Observe that the Profile
MonitorThreads dialog box appears.
- Select Monitor on the
left of the dialog box.
- Check Enable threads monitoring
(if it is not been selected already) (Figure-3.23 below)
- Click Run.

Figure-3.23: Analyze Performance pane
2. Click Start button when application GUI appears. (Figure-3.24 below)

Figure-3.24: Click Start button
3. Observe the Threads status.
- Observe that the Threads window appears.
- Observe that the AWT-EventQueue-0 thread turns green and stay
that way for a full thirty seconds.

Figure-3.26: thread information
<Study points> The color of a thread indicates different
state of the thread.
- Green: the thread is either running or is ready to run.
- Purple: the thread is sleeping in Thread.sleep().
- Yellow: the thread is waiting in a call to Object.wait().
- Red: the thread is blocked while trying to enter a synchronized
block or method.
This graph shows why the application is not responding. The thread
labeled AWT-EventQueue-0 is the
Event Dispatch Thread (EDT) used by
Swing to process
window events. In a well behaved Swing application, the EDT spends most
of its time waiting and very little time running; it should only run
for the brief amount of time required to dispatch an event. If the
event handlers in the application do not return quickly, however, then
the program will become unresponsive, just like in this example.
</Study points>
4. Close the application and stop the profiling.
- When the sample GUI application is able to respond again, click
its Exit button to shut it down. If a dialog is displayed
notifying you that the profiled application has finished execution,
click OK.
- Stop the profiling.
return to top of the exercise
(3.3)
Look under the hood of the ill-behaving application
1. Display the DisplayForm.java, which contains badly designed code.
- Expand MonitorThreads->Source Packages->profilingthreads.
- Double click DisplayForm.java to open it in the editor window.
- Observe the badly-designed code fragment between line 122 and
128, which is highlighted in blue-colored shade in Figure-3.31
below. The code basically waits for 30 seconds before it
returns control.

Figure-3.31: Badly designed code
return to top of the exercise
(3.4)
Correct the badly designed code and profile again
1. Remove the badly designed code from line 122 to line 128. The result
should be as shown in Figure-3.41 below.

Figure-3.41: Remove the badly designed code fragment
2. Use SwingWorker thread.
- Uncomment the code fragment that uses the SwingWorker.
(Figure-3.42 below)

Figure-3.42: Uncomment the code fragment that uses SwingWorker
3. Run the application with profiling.
- Right click MonitorThreads project
node and select Profile.
(Figure-3.43 below)

Figure-3.43: Profile the application with corrected code
- Observe that the Profile
MonitorThreads dialog box appears.
- Select Monitor on the
left of the dialog box.
- Check Enable threads monitoring
(if it is not been selected already) (Figure-3.44 below)
- Click Run.

Figure-3.44: Monitor Application
4. Click Start button and observe that it responds correctly.
(Figure-3.45 below)

Figure-3.45: Click Start button
5. Observe the thread status.
- Observe that the Threads window appears.
- Observe that the AWT-EventQueue-0 thread (EDT) is in yellow most
of the time and the thread created by the application, which is named
"Our SwingWorker #1" is green. The EDT is not being used to do a time
consuming task and as a result the buttons and other program controls
remain responsive. (Figure-3.46 below)

Figure-3.46: Thread status
6. Display the Threads Details.
- Right click AWT-EventQueue-0 and select Thread Details.
(Figure-3.47 below)

Figure-3.47: Thread Details
- Observe that the information on the thread is displayed in pie
chart form. (Figure-3.48 below)

Figure-3.48: Thread details
- Click Details tab window. (Figure-3.49 below)

Figure-3.49: Details information
5. Stop the profiling.
- Click Stop profiling icon (red box with white-colored x inside)
return to top of the exercise
Summary
In this exercise you learned how to use
the Profiler to start an application and how to interpret the
Profiler's thread information graphs in order to track down a
performance problem in a Swing application.
Exercise 4: Profile
"ComputePrimeNumberWebapp" application
(4.1)
Build and run
"ComputePrimeNumberWebapp" sample application
1. Open
Java2D
NetBeans project.
- Select File->Open Project (Ctrl+Shift+O).
- The Open Project dialog
box appears.
- Browse down to and expand <LAB_UNZIPPED_DIRECTORY>/nbprofilerperformance/samples
directory.
- Select ComputePrimeNumberWebapp.
- Click Open Project.
- Observe that the ComputePrimeNumberWebapp
project node appears under Projects tab
window.
2. Build and run the application and observe the performance problem.
- Right click ComputePrimeNumberWebapp
project
node and select Run.
- Observe that browser gets displayed. (Figure-4.11 below)
- Click Submit Query
button. (Figure-4.11 below)

Figure-4.11: Welcome to We-have-performance-problems.com page
- After 10 to 15 seconds later, observe that the result is
displayed in the browser. (Figure-4.12 below) This is the case
where the prime number generation is done by a badly-designed
code. This is the performance problem we would like to solve.

Figure-4.12: Experience the performance problem
3. Run the application with the optimized code.
- Check optimized check box
- Click Submit Query.
(Figure-4.13 below) This time, highly optimized prime number
generation code will be used.

Figure-4.13: Do the prime number generation with optimized code
- Observe that with the optimized prime number generation code, it
takes only 31 milli second. (Figure-4.14 below)

Figure-4.14: Result of using optimized prime number generation code
return to top of the exercise
(4.2)
Run "ComputePrimeNumberWebapp" application in profiling mode
1. Run the application in profiling
mode.
- Right click ComputePrimieNumberWebapp
project node and select Profile (Figure-4.21 below)

Figure-4.21: Profile the application
- Observe that the Enable
Profiling of ComputePrimeNumberWebapp dialog box appears.
- Click OK. (Figure-4.22 below)

Figure-4.22: Confirm the profiling
2. Define a new root method.
- Observe that the Profile
ComputePrimieNumberWebapp dialog box appears.
- Click CPU on the left
(if it has not been selected already).
- For Filter, select Profile all classes for now.
(Later on, you are going to change it to Profile only project
classes.)
- Select Part of the application.
- Click define.. link
just beside of the Part of application.
(Figure-4.23 below)

Figure-4.23: Define the root method
- Observe that the Specify Root
Methods dialog box appears.
- Click Add From Project
button. (Figure-4.24 below)

Figure-4.24: Add Root method
- Observe that the Select Root
Methods dialog box appears.
- Expand CompuetPrimeNumberWebapp->Servlets->Methods.
- Select processRequest(..)
method at the end. (Figure-4.25 below)
- Click OK.

Figure-4.25: Select a root method
- Observe that the processRequest(..)
method is now added as a root method. (Figure-4.26 below)
- Click OK.

Figure-4.26: processRequest(..) method is added as a root method
- Observe that now 1 root method
is displayed. (Figure-4.27 below)
- Click OK.

Figure-4.27: 1 root method is displayed
3. Observe the result.
- Observe that the browser gets displayed.
- Click SubmitQuery.
- Wait some seconds to see the result. (Figure-4.28 below)

Figure-4.28: Result is displayed.
4. Take the snapshot of the profiling.
- Click Take Snapshot icon.
- Observe that the profiling result is displayed on the right side
of the IDE.
- Notice that the time spent in the system code - any classes with org.apache.* or java.lang.* - are negligible and
most of the performance overhead comes from the application itself - demo.Performance.*.
(Figure-4.31 below) You want to profile only the project classes
in the subsequent profiling.

Figure-4.31: Profiling result
return to top of the exercise
(4.3)
Modify Profiling
1. Modify the profiling.
- Select Profile from the
top-level menu and select Modify
Profiling Session. (Figure-4.41 below)

Figure-4.41: Modify Profiling Session
- For Filter, select Profile only
project classes. (Figure-4.42 below)
- Click OK.

Figure-4.42: Profile only project classes
3. Observe the result.
- Observe that the browser gets displayed.
- Click SubmitQuery.
- Wait some seconds to see the result. (Figure-4.28 below)
4. Take the snapshot.
- Click Take Snapshot icon.
- Observe that the profiling result displays only the methods of
the project.
- Right click demo.primenumbers.PrimeNumbers.caculate() and select Go to Source. (Figure-4.43 below)

Figure-4.43: Profiling result.
- Observe that the source code of the calculate(..) method is displayed in
the editor window. (Figure-4.44 below)

Figure-4.44: Source code of the calculate()
5. Stop the profiling.
- Click Stop profiling icon (red box with white-colored x inside)
return to top of the exercise
Summary
In this exercise you learned how to have
the Profiler do performance analysis on a method.
return to
the top
Homework
Exercise (for people
who
are taking Sang Shin's "Advanced Java SE Programming online course")
<to
be provided>