Analyzing Program Performance With Sun WorkShop

Collecting Sampling Data

Before you can collect data:

To collect data:

  1. In the Debugging window, choose Windows > Sampling Collector to open the Sampling Collector Window (see Figure 2-1)..

  2. Select whether you want to collect data for only one run or for all runs.

    If you run the Sampling Collector for only one run, the Sampling Collector shuts off after the first experiment is created. If you leave the Sampling Collector on for all runs, the Sampling Collector remains on, and subsequent executions record additional experiments.

    Turning the Sampling Collector on does not start data collection. Performance data is collected only when you execute the program in the Debugging window.

  3. Enter the complete path name for your experiment file in the Experiment File text box.

    The Sampling Collector provides the default experiment-record name test.1.er. If you use the .1.er suffix for your experiment-record filename, the Sampling Collector automatically increments the names of subsequent experiments by one--for example, test.1.er is followed by test.2.er.

  4. Select the data to be collected.

    Summary data is always collected, but most users want to collect information about functions that are executed as well; to do so, select Execution Profile data. Execution profile data can include or exclude time spent in called functions. Most users want to include such time; to do so, select Include called function time.

    If you are concerned about your application's memory usage, you should select Address Space data.

    Data is collected in terms of samples, each representing a sample of the program's execution. By default, samples are collected periodically. If you select Manually, on `New Sample' command, samples are marked in response to the new sample command or button. Whether you collect samples manually or periodically, additional samples are always marked when the program encounters a breakpoint.

  5. Start the program running in the Debugging window by clicking either Start or Go.

    Start begins sampling the program from the beginning of the code. Go begins sampling it from the current location in the code.

    Figure 2-2 Sampling Collector Window

    Graphic

 Collect menu Provides commands to start program sampling, break program sampling, start the Sampling Analyzer, and exit the Sampling Collector.
 Collect Data radio buttons Turn the Sampling Collector off, on for one run, or on for all runs. If you select for one run only, the Sampling Collector turns off after an experiment is created. If you select for all runs, the Sampling Collector remains turned on even after the experiment is created. Turning the Sampling Collector on does not start data collection. Performance data is collected only when you execute the program in the Debugging window.
 Experiment File text box Accepts the complete path name of your experiment. You can either type in the path yourself or select it through the file chooser, which can be accessed by clicking the ellipsis button (...) to the right of the text box.
 Address Space data checkbox Collects process state address space data represented as a series of segments, each of which contains a number of pages. Such data allows the Sampling Analyzer to describe the status of each page and whether it was referenced or modified.
 Execute Profile data checkbox Collects information about the time consumed by functions, modules, and segments during the execution of the application.
 Collect Profile data slider Controls how many samples per second the Sampling Collector gathers.
 Profile Times radio buttons Determine whether called function times are included in or excluded from the sample data.
 Manually, on "New Sample" command radio button Summarizes data and starts a new sample whenever you choose Collect New Sample.
 Periodically radio button Collects data periodically at the interval set by the Period slider (default is one second).
 Period slider Determines the interval at which period data is collected.

Controlling Profile Frequency

You can specify, in intervals of seconds, how often the Sampling Collector records profile PCs and call stacks. The valid range for the interval is 1 to 100 samples per second.

To specify an interval for gathering profiles, move the Collect Profile data slider to the number of samples per second you want.

Marking Samples

The Sampling Collector interrupts data gathering to end one sample and begin another at these three points:

Breakpoints

Because data is always summarized at breakpoints in the code, you can set breakpoints at any location at which you want to summarize collected data.

New Sample Command

If you select the radio button labeled "Manually, on `New Sample' command", you can use the New Sample command on the Collect menu to check data at whatever points in the application you wish without setting a breakpoint in the code. This is useful if you are interested in measuring human interaction with the application--for example, the time it takes to choose a command from a menu or to type in a keyboard command.

Periodic Sampling

If you select the radio button labeled "Periodically", the Sampling Collector takes behavior data samples as you observe the running application, to give you a uniform view of the application's behavior. Use the Period slider at the bottom of the Sampling Collector window to define the intervals at which the Sampling Collector summarizes samples. The interval can be from 1 to 60 seconds.