Specify profiling criteria

Profiling an application requires the selection of one or more analysis type under the Java Profiling data collector. Data collectors specify how data should get collected and analysis types indicate what type of data is to be collected. Filters ensure that only relevant details are channeled out to the views. Using filters is especially useful when speed and efficiency is critical: the less data there is, the less impact it has on the system, and the faster it can be collected. Prerequisites:

 

Configuring the profiling criteria for an application is broken down into the following sections:

 

Selecting the relevant data collectors and analysis types

  1. In your profiling configuration, select the Monitor tab.

  2. The tree pane displays data collectors at root level and analysis types as the children of the data collector. Expand the 'Java Profiling' data collector and notice the analysis types that fall under it (for example: 'Execution Time Analysis', 'Probe Insertion', and so on...).
    Select the analysis types that you are interested in under the 'Java Profiling' data collector. The features supported for profiling Java 1.5 and Java 1.4 based java virtual machines are described below.

     

Profiling Java 5.0 (Java 1.5) and higher java virtual machine based applications

Profiling Java 1.4 and lower java virtual machine based applications

 

Profiling Java 5.0 (Java 1.5) and higher java virtual machine based applications

Java Profiler support for profiling Java 5.0 and higher JVMs is based on the Java Virtual Machine Tool Interface (JVMTI) introduced in J2SE 5.0, which replaces the earlier experimental Java Virtual Machine Profiler Interface (JVMPI). The Profiler uses a substantially different approach from the JVMPI-based Profiler. Instead of relying on VM-generated events for monitoring application behavior (such as method entry and exit events, object allocations and so on) it uses Byte Code Instrumentation (BCI) to inject small pieces of code which track the application execution. This technique allows for efficient monitoring of specific parts of the application, without imposing a noticeable overhead on other parts of the application that are not being monitored. This approach is easy to use and scales well for large applications.

Execution Profile of an Application

The Java profiler can be used to profile any Eclipse plug-ins, Eclipse RCP applications, J2EE applications, and Java applications. To profile an application select "Open Profile Dialog..." from the Profile drop down menu (see Figure). This opens the profile launch configuration window.

Profile Drop Down Menu


 
Perform the following steps:

Memory (Object allocation) analysis

To perform an Object Allocation analysis or Memory analysis (Heap), perform the following steps:

Thread Profile of an Eclipse Application

To perform a thread profile of your application, perform the following steps:

Probe Insertion

To instrument your application using probes, perform the following steps:

 

 

Profiling Java 1.4 and lower java virtual machine based applications

Java Profiler supports Java 1.4 and lower profiling. The profiler enables profiling for determining performance bottlenecks and memory analysis of your application.

The Java profiler enables support of multiple analysis types. Depending on the size of the application and the type of analysis required, limit the number of analysis types to be selected for your profiling session. Refer to the table below to see which profiling types should be enabled to generate the different views, and possible applications of each profiling type. Setting options will be described in the next section.
Analysis type Options selected Views available Application
Memory Analysis N/A Memory Statistics view (Package, Class, Method), Object References view* Memory leak analysis, Identifying memory-intensive classes
Memory Analysis Advanced >> Instance Level information check box selected Memory Statistics view (Package, Class, Method, Instance) Object References view* Memory leak analysis, Studying Garbage Collection
Time Analysis Show execution Statistics (compressed data) Execution Statistics (Package, Class, Method) Coverage Statistics Viewing invocations of a method
Time Analysis Show execution Statistics (compressed data), Advanced >> Collect instance level information Execution Statistics (Package, Class, Method, Instance) Coverage Statistics Viewing package, class and method statistics for each instance, Viewing invocations of a method
Time Analysis Show execution graphical details Execution Statistics (Package, Class, Method), Coverage Statistics, Execution Flow view, UML2 Sequence diagrams views (object,class, thread) Identifying active threads, Identifying phases of program execution
Time Analysis Show execution graphical details, Advanced >> Collect instance level information Execution Statistics (Package, Class, Method, Instance), Coverage Statistics, Object References view**, Execution Flow view, UML2 Sequence diagrams views (object,class, thread) Identifying active threads, Identifying phases of program execution
Code Coverage N/A Coverage Statistics (Package, Class, Method) Viewing code coverage

Notes:

* For the Object References view, you will need to collect object references by invoking the action Collect Object References to view the profiling data using the Object References view. You can invoke Collect Object References from the toolbar of the Profiling Monitor view or by right clicking on the agent in the Profiling Monitor view.

** For the Object References view, you will need to collect object references by invoking the action Collect Object References to view the profiling data using the Object References view. You can invoke Collect Object References from the toolbar.

 

Setting profiling options

You can set profiling options for the Java Profiling data collector or the selected analysis types, by highlighting the entity and clicking Edit Options.

Follow the steps below to set profiling options on the Java Profiling data collector:

  1. Highlight Java Profiling and click on Edit Options

  2. By default, all classes are profiled. You can change this on the Filter Set page by specifying the filter set to be applied to your profiling session. Under the Select a filter set list, click Add to add the desired filter set.

  3. You can also specify the filtering criteria manually. Under Contents of selected filter set, click Add to add packages for which you want to collect data. The Add Filter dialog opens. An asterisk * can be used as a wildcard in a pattern when specifying package or method names.
    Notes:

    1. When entering a pattern for the package or method name, the pattern must be specified in one of three ways:

      • A pattern with no wildcards, e.g. org.eclipse.tptp.

      • A pattern with a wildcard at the beginning, e.g. *.sample.myapplication.

      • A pattern with a wildcard at the end, e.g. org.eclipse.*.

    2. Certain classes will always be visible in the profiling views regardless of the filter settings. The profiling agent will always collect data for objects or classes that are associated with the task being examined while collecting data specific to the task. For example, you specify a filter to collect data for a single class MyUserClass, and specify another filter to exclude the java.lang.* classes. When an instance of MyUserClass is loaded though, it has an associated class definition that gets loaded. This class definition has an associated class object, which is in turn of type java.lang.Class. This results in data collection for the java.lang.Class in addition to the MyUserClass class.
      This behavior applies to threads as well. The java.lang.Thread class will always show up in the Profiling views because the profiling agent tracks all running threads, and therefore, collects data for objects or classes associated with those threads.

  4. Specify the Package or Class, Method Name that you wish to filter. If you want see the profiling data for these packages, classes, methods, select Include from the Rule drop-down list. If you want to exclude these packages, classes, methods, from the profiling data click on Include under the Rule column for the package, and change it to Exclude.

  5. Click OK. The filter criterion is added to the contents list.

  6. On Java 1.5 and higher, click Finish and proceed to step 11 below. On Java 1.4 and lower, click Next and proceed to the next step.

  7. To limit the data collected by method invocations select the Stop profiling after specified number of method invocations check box. Specify the number of method invocations in the input box provided.

  8. To limit the data collected by time, select the Stop profiling after specified amount of time check box. Specify the amount of time in seconds in the input box provided.

  9. To start the profiling agent automatically when the application is launched, check the Automatically start monitoring when application is launched check box. Note: It is strongly recommended for large applications that are not required to be monitored during the initialization phase (for example launching an instance of the workbench), that you accept the default and leave the Automatically start monitoring when application is launched check box not selected. This will result in the profiling agent being started in pause mode so that data is not collected during the initialization stage of the application.

  10. Click Finish

  11. Click Apply to save the changes.

Similarly, you can set the options of an analysis type by highlighting it and selecting Edit Options.

 

Configuring the profiling data destination

You can specify the project, and the monitor to use for your profiling session. You can also write the profiling data to a file.

  1. In your profiling configuration, select the Destination tab.

  2. Specify the Profiling Project that you want to use for your profiling session.

  3. Specify the Monitor that you want to use.

  4. If you want to save the profiling data to a file, select the Send profiling data to a file and specify the file name in the Profiling file input box.

  5. Click Apply to save the changes.

  6. Click Profile to start profiling your application.
Hint: When filtering, only the first applicable filter is applied. When you are specifying filters, ensure that you declare the most specific filter criteria first.

 

Related concepts
Overview of the Java Profiler

Related tasks
Profiling an application
Setting profiling preferences