Identifying resource-intensive methods
Resource-intensive methods affect the overall performance of a program's execution. Using the Execution
Flow view and the Method Invocation view can help you to easily identify these methods that can be candidates
for optimization.
Prerequisites:
A method may be a candidate for optimization if one of the following statements apply:
- The method is called more frequently than required. Performance can be enhanced
by finding ways to either make fewer calls or to make small improvements to a
method that is frequently used.
- The method has a long execution time. Alternately, performance can be enhanced by identifying the
classes that take up the most execution time and then optimizing those methods
that spend a long time on the stack. Such methods may not necessarily be executing but may
instead be
calling other methods for tasks such as sorting or delegating.
Locating frequently called methods
To locate frequently called methods:
- In the Profiling Monitor view select either a monitor or an agent.
- Right click, then select Open With > Execution Flow. The Execution Flow view opens.
- Click the Zoom In button
to enlarge
a sequence of method calls.
- Right-click on a method name in the graphical view, and select
Detect All Repetitions. You see X appear where there are
repeated patterns.
- Zoom in on those areas to see the repeated patterns and
the number of repetitions of the method.
Locating methods with long execution times
To locate methods with a long execution time:
- In the Execution Flow view, examine the length of each method's stripe. The longer the stripe, the
longer the execution time.
- To see a method in greater detail, open the Method Invocation view by selecting the
method, right-click, and selecting Show Method Invocation. The Method Invocation
view opens.
- In the Method Statistics view, to see the execution time of the method's caller, right-click then select Show Method Invocation.
This view shows a representation of the same method as a labeled line.
- From the local toolbar, click Show Caller
to see the callers of
the selected method in the view. Each time you click this button, one method
higher up in the calling sequence is displayed.
- Select a method. The vertical length of the selected area indicates the
base time for the method. You can determine the execution time for this
method by checking the vertical time scale on the right side of the view. The
status line gives you the cumulative time for the method.
Obtaining a broad view of program execution
To get a wide view of execution time:
- Open the Execution Flow view: From the pop-up menu of the monitor in the
Profiling Monitor view, select Open With > Execution Flow.
- This view, like the Method Invocation view, this view has a vertical time
scale along its right side.
- Use the Zoom In
button to enlarge a particular
section of the view to highlight the method that you want to examine.
- Click the method name (or on white space below it) to select it. The
vertical length of the highlighted area is an indication of the base time for
the method. The exact value for the base time is displayed in the status
line.
- Use the Zoom Out button
to view a larger
portion of the entire program while still being able to see the highlighted
area of the method (that is, you can still see the yellow rectangular area).
Even if the entire execution representation is not seen, you can still
determine how much time this method consumes in relation to the entire
program.
Related concepts
Overview of the Profiling Tool
Execution flow view and table
Statistical views
Related tasks
Profiling an application
Launching or attaching a Java process
Studying garbage collection
(C) Copyright IBM Corporation 2000, 2006. All Rights Reserved.