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:

 

Locating frequently called methods

To locate frequently called methods:

  1. In the Profiling Monitor view select either a monitor or an agent.

  2. Right click, then select Open With > Execution Flow. The Execution Flow view opens.

  3. Click the Zoom In button to enlarge a sequence of method calls.

  4. Right-click on a method name in the graphical view, and select Detect All Repetitions. You see X appear where there are repeated patterns.  

  5. 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:

  1. In the Execution Flow view, examine the length of each method's stripe. The longer the stripe, the longer the execution time.

  2. 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.

  3. 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.

  4. 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.

  5. 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:

  1. Open the Execution Flow view: From the pop-up menu of the monitor in the Profiling Monitor view, select Open With > Execution Flow.

  2. This view, like the Method Invocation view, this view has a vertical time scale along its right side. 

  3. Use the Zoom In button to enlarge a particular section of the view to highlight the method that you want to examine.

  4. 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.

  5. 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