The Sampling Collector can gather:
Summary data for the application
Execution profile data with or without called function times
Program memory usage data
The Sampling Collector records data samples, each sample representing a portion of a run. To display the data for any set of such samples, you use the Sampling Analyzer.
Summary statistics are always collected, and include two kinds of data. The first kind is shown on the initial screen of the Sampling Analyzer, and is a summary of the amount of time the program spent in various states. States include user time, system time, system wait time, text page fault time, and data page fault time.The second kind of statistics is shown in the "Execution Statistics" screen of the Analyzer, and includes page fault and I/O statistics, context switches, and a variety of page residency (working-set and paging) statistics.
Execution profile data shows how much time is consumed by functions, modules, and segments while the application is running. It can be displayed in the Sampling Analyzer as a histogram or as a cumulative histogram (if called-function times are included).
Execution profile data helps answer the following kinds of questions:
How much time does the application spend executing various functions, object modules, or segments?
What functions, modules, or segments are consuming the greatest amount of time?
If called-function times are included in the sample, how much time is spent by functions that call other functions?
Address space data represents the process address space as a series of segments, each of which contains a number of pages. It allows the Sampling Analyzer to describe the status of each page and whether it was referenced or modified. Program memory-usage data can be displayed in the Sampling Analyzer in the Address Space display.
Address space data helps answer the following kinds of questions:
How does memory usage change over time?
Is the application using pages efficiently?
Which pages are accessed during a particular operation?
Before you can collect data:
Your program must be loaded in the Sun WorkShop Debugging window.
Runtime checking must be turned off.
To collect data:
In the Debugging window, choose Windows > Sampling Collector to open the Sampling Collector Window (see Figure 2-1)..
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.
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.
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.
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.
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. |
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.
Decrease the frequency if you want to decrease your data-collection overhead and don't mind having less precisely accurate data.
Increase the frequency if you want more accurate data and don't mind higher data-collection overhead.
To specify an interval for gathering profiles, move the Collect Profile data slider to the number of samples per second you want.
The Sampling Collector interrupts data gathering to end one sample and begin another at these three points:
At breakpoints
When you choose Collect New Sample
Periodically, at intervals you set with the slider
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.
If your application is compiled using the -g option, you can set breakpoints in those specific areas of the code pertaining to the information you want to collect. The breakpoints can be set at the beginning or end of a function, or on any line of code.
If the application is compiled with the -O option, you can set breakpoints on functions, but not on specific source-code lines.
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.
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.