Identifying resource-intensive methods

A method may be a candidate for optimization if it is:

To locate frequently-called methods, do the following:

  1. Ensure that the collection of execution flow information has been enabled, which you do when launching or attaching to the application to be profiled.  Select the profiling option, My application is too slow then, from the Details options, select Show Execution flow graphical details
  2. In the Profiling Monitor view select either a monitor or an agent.
  3. Right click, then select Open With > Execution Flow. The Execution Flow view opens.
  4. Click the Zoom In button zoom in button icon to enlarge a sequence of method calls.
  5. Right-click, then select Detect All Repetitions. You see Xs appear where there are repeated patterns.  
  6. Zoom in on those areas to see the repeated patterns and the number of repetitions of the method. 

To locate methods with long execution time, do the following:

  1. Launch or attach a process for a particular resource, then open the Execution Flow view. 
    Note:
    You can open the view from the agent, the process, the host, or the monitor.  Realize, however, that  the information from these resources is quite different. For example, the Execution Flow view from the agent shows the execution of the specific JVM (Java virtual machine) to which the agent is attached. In contrast, selecting the view from the monitor shows the execution of all of JVMs that have profiling agents under the selected monitor.
  2. Notice the length of each method's stripe. The longer the stripe, the longer the execution time.
  3. To see a method in greater detail, open the Method Statistics view, select the method, right click, and then select Show Method Invocation.
  4. 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.
  5. From the local toolbar, click Show Caller caller button icon 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.
  6. 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.

To get a wide view of execution time, do the following:

  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 zoom in button icon 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 zoom out button icon 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
Analyzing performance and memory usage - overview