Using Sun WorkShop

Analyzing Performance Data

After you collect performance data with the Sampling Collector, you can view it only through the Sampling Analyzer, a separate tool available from the Sun WorkShop main window or by choosing Collect > Analyze in the Sampling Collector window. The three types of data you can collect with the Sampling Collector separate into nine types of data available to analyze; each of these nine types of data has one or two Analyzer display options associated with it.

Types of Data You Can View and Analyze

You can analyze the following types of data by selecting them from the Data list in the Sampling Analyzer window:

For more information on selecting a data type, see "Selecting Data Types" in the Sun WorkShop online help.

Display Options

The Sampling Analyzer offers five ways to view collected performance data:

For more information on selecting a display option, see "Selecting Display Options" in the Sun WorkShop online help.

Comparing Samples

By choosing View > New Window in a Sampling Analyzer window, you can open a new Analyzer window to compare two samples or view the same set of samples in two different ways.

Reordering Program Functions

If text page faults are consuming a lot of your application's time, the Sampling Analyzer can reorder your program, generating a mapfile containing an improved ordering of functions. With the most-used functions grouped together on the same set of pages, a function is more likely to already be in memory when called.

The --M option passes the mapfile to the linker, which then relinks your application and produces a new executable application with a smaller text address space size.

After you have reordered your application you can run a new experiment and compare the original version with the reordered one.

To reorder an application, compile the application using the --xF option.

The --xF option is required for reordering. This option causes the compiler to generate functions that can be relocated independently.

For C applications, type:

cc -xF -c a.c b.c cc -o application_name a.o b.o

For C++ applications, type:

CC -xF -c a.cc b.cc CC -o application_name a.o b.o

For Fortran applications, type:>

f77 -xF -c a.f b.f f77 -o application_name a.o b.o

If you see the following warning message, check any files that are statically linked, such as unshared object and library files, because these files may not have been compiled with the --xF option:


ld: warning: mapfile: text: .text%function_name: object_file_name: Entrance criteria not met the named file, function_name, has not been compiled with the --xF option.

  1. Load the application in Sun WorkShop for debugging.

  2. Start the Sampling Collector by choosing Windows > Sampling Collector from the Debugging window.

  3. Run the application in Sun WorkShop.

  4. Load the specified experiment into the Sampling Analyzer.

  5. Create a reordered map in the Sampling Analyzer by choosing Experiment > Create Mapfile. In the file chooser, enter the samples to be used, the mapfile directory, and the name of the mapfile to be created, and click OK.

    The mapfile contains names of functions that have user CPU time associated with them. It specifies a function ordering that reduces the size of the text address space by sorting profiling data and function sizes in descending order. All functions not listed in the mapfile are placed after the listed functions.

  6. Link the application using the new mapfile.

    For C applications, type:

    cc -Wl -M mapfile_name a.o b.o

    For C++ applications, type:

    CC -M mapfile_name a.o b.o

    For C applications, the --M option causes the compiler to pass --M mapfile_name to the linker.

    For Fortran applications, type:

    f77 -M mapfile_name a.o b.o

Printing

You can print a plain text version of the current display or a text summary of the experiment (including average sample times for each data type and the frequency of use of functions, modules, and segments). Choose Experiment > Print or Experiment > Print Summary in the Sampling Analyzer window and type the appropriate information in the dialog box.

Exporting Experiment Data

You can export collected experiment data to files for use by other programs (such as spreadsheets or custom-written applications).

To export experiment data to an ASCII file:

  1. Type the directory of the experiment file to be exported in the Directory text box and the name of the file in the File text box.

  2. Choose Experiment > Export.

  3. Click OK to save the experiment data under the given file name.