Tool Mentor: Finding Performance Bottlenecks Using Rational Quantify and Rational
PurifyPlus (UNIX)
Purpose
This tool mentor provides an overview of how to use Rational Quantify to
quickly pinpoint performance bottlenecks in your programs.
PurifyPlus is a Rational product that includes Quantify
functionality.
To learn more about Quantify and for step-by-step instructions, read Installing
and Getting Started: Rational Purify, Rational PureCoverage, Rational Quantify.
For step-by-step instructions for using Quantify and for reference
information, see Quantify online Help.
Related Rational Unified Process information:
Overview
Quantify provides a complete, accurate set of performance data for
your program and its components (including threads), and displays it in an
understandable and usable format so you can see exactly where your program
spends most of its time.
Tool Steps
To profile a program's performance:
- Instrument and run a program with Quantify to collect performance
data
- Analyze the performance data
- Run the program again and compare runs to find performance changes
1. Instrument and run a program with Quantify to collect
performance data 
The first step in profiling your program's performance is to collect
performance data.
Just add the word quantify to the
beginning of your compile/link line. Quantify collects performance data at the function level and, if you compile with the -g
debugging option, at the line level. For example:
% quantify cc -g hello_world.c
Quantify makes a copy of your object code and libraries, and
instruments it using Object Code Insertion (OCI) technology to insert
instructions for collecting performance data. When instrumentation is complete, run the instrumented program. For
example:
% a.out
As you exercise your code, Quantify records data about its
performance. You can call Quantify API functions from your program to pause and
resume data recording at any time, enabling you to profile specific portions of
code.
When you exit the program, Quantify displays the Quantify Control Panel, from which you can access
its data analysis windows and begin analyzing
your programs performance.
Tip: In addition to using Quantify interactively, you can also
use it with your test scripts, makefiles, and batch files for automated
testing. View output from your tests using the command
qv a.out.<process id>.<sequence
number>.qv.
For more
information, look up the following topics in the Quantify online Help index:
- basic steps
- scripts
- options
- API functions
2. Analyze the performance data 
The second step in profiling your program's performance is to analyze the
performance data that Quantify has collected.
From the Quantify Control Panel, which is displayed when you exit
the program for which you have been collecting data, you can open the Call
Graph window or the Function List window to examine the data in different
formats. From these windows you can open the Function Detail window and the
Annotated Source window.
The Call Graph window displays a schematic representation of the
calling structure and performance of the functions in the program. By default,
the call graph displays the 20 functions that contributed most to the overall
time of the program. As you examine your program's performance, you can show
additional functions, hide functions, and focus on the specific functions and
their descendants that are most critical for your work.
The Function List window displays in table format the statistics for
the functions. You can sort them on the basis of a large number of criteria,
such as the time the program spends in the function, the time the program spends
in the function and its descendants, and the number of calls the function makes.
The Function Detail window displays data for a specific function, and
data about its callers and descendants.
The Annotated Source window displays line-by-line performance data on
a copy of your source code. This is available if you compiled with the -g
debugging option.
Quantify's results include virtually no overhead from the profiling
process itself. The numbers you see are the time your program would take without
Quantify.
For more
information, look up the following topics in the Quantify online Help index:
- call graph
- function list
- function detail
- annotated source
3. Run the program again and compare runs to find performance changes 
The third and final step in profiling your program's performance is to make
changes to your code, and compare "before" and "after"
performance data to see whether the code changes have caused the performance to
improve or regress.
After you make changes to your code, you can rerun the updated program and
use Quantify's qxdiff script
to compare the new results to any previous run.
You can save performance data as a Quantify data file (.qv) to use for further
analysis or to share with other Quantify users. You can save data in export
format for use outside of Quantify.
For more
information, look up the following topics in the Quantify online Help index:
Copyright
© 1987 - 2001 Rational Software Corporation
|