Exercise 1.2: Collecting performance and coverage data

Before you begin, you must complete Exercise 1.1: Importing the required resource.

Scenario: You have been asked to investigate a Java project because something is odd about its performance. The project includes a bubble sort and a quick sort. The bubble sort, contrary to expectations, is faster than the quick sort. Your assignment is to use the runtime analysis tools in the Software Development Platform to discover the reason for this behavior.

Because this is a performance problem, you decide to collect performance data for display in the Performance Call Graph view. You also decide to collect method and line code coverage data at the same time. Collecting coverage data helps you ensure that you are testing all parts of your code.

Preparing to collect performance and coverage data

To collect performance and coverage data, you must be in the Profiling and Logging perspective.

To switch to the Profiling and Logging perspective:

  1. From the Software Development Platform menu bar, select Window > Open Perspective > Other...
    The Select Perspective dialog box opens.
  2. In the lower left of the dialog box, click Show all.
    A check appears in the check box.
  3. From the list of perspectives, select Profiling and Logging and click OK.
  4. If the Confirm Enablement dialog box opens, click Always enable capabilities and don't ask me again, and then click OK.
    The Software Development Platform switches to the Profiling and Logging perspective.

Collecting performance and coverage data for the sort application

The following procedure runs the sort application and collects performance data to identify areas where slow performance is causing unexpected results. It also collects method and line code coverage data, which shows whether all parts of the application are being exercised.

To collect performance and coverage data:

  1. From the Software Development Platform menu bar, select Window > Show View > Console to open the Console view. The Console view allows you to follow the application as it processes.
  2. Create a profiling configuration. (A profiling configuration is a reusable set of instructions for collecting data from a specific project.)
    1. From the menu bar, select Run > Profile...
      The Profile dialog box opens.
    2. In the Configurations list, double-click the Java Application entry.
      A New_configuration entry appears.
    3. In the Name field, type sort_perf_plus_cov.
    4. In the Main tab, if Sort is not already entered in the Project field, do the following:
      1. Next to the Project field, click Browse.
        The Project Selection dialog box opens.
      2. Select Sort and then click OK.
    5. Next to the Main class field, click Search.
    6. In the Choose Main Type dialog box, select Sort, and then click OK.
    7. In the Profile dialog box, click the Profiling tab.
    8. In the Overview sub-tab, click Add to add a profiling set. (A profiling set defines the type of profiling data that is to be collected for the run.)
      The Add Profiling Set dialog box opens.
    9. For Profiling Set Name, type Performance and Coverage.
    10. Click OK.
    11. Click Edit. The Edit Profiling Set dialog box opens.
    12. Expand the entry for Code Coverage.
    13. Select the check box for Method and Line Code Coverage.
    14. Expand the entry for Time Analysis.
    15. Select the check box for Execution Time Analysis.
    16. In the Execution Time Analysis page, select the radio button for Show execution flow graphical details.
    17. Click Finish.
      The profiling set now includes two profiling types (Execution Time Analysis and Method and Line Code Coverage).
  3. Click Profile.
    The application runs, and the display changes as follows:

The output looks something like this:

***************************************

Median of  10000  sorted numbers is : -22682115

*****************************************


***************************************

Median of  10000  sorted numbers is : -22682115

*****************************************

If you were unable to collect data

Before you can collect any kind of profiling data, Agent Controller must be running. If you get a message that Agent Controller is not available, make sure that Agent Controller has been installed, start it manually, and try again. For instructions, refer to the installation guide. You can access the installation guide by using the installation launchpad, or you can find it on the product CD under disk1/install.html.

After you collect data, you are ready to begin Exercise 1.3: Identifying a performance bottleneck.

Terms of use | Feedback
(C) Copyright IBM Corporation 2000, 2005. All Rights Reserved.