HP Caliper User's Guide

2 Getting Started with the HP Caliper Command-Line
Interface
This chapter provides some example programs to show you how to get started using
the HP Caliper command-line interface. The programs are chosen for illustration
purposes and are not necessarily representative of programs you might actually want
to analyze.
Example: Running fprof on a Short Program, with Default Output
HP Caliper provides many types of performance measurements. You typically specify
which type of measurement to perform by the first argument to the caliper command.
A good measurement to start with is fprof (flat profile), which will show you the
parts of your application that have the highest CPU usage. When you specify fprof,
HP Caliper samples your application's instruction pointer (IP) at regular intervals
(every 500,000 CPU cycles by default) and reports which functions and source lines
incurred the most IP sample hits. Because HP Caliper uses samples, rather than precise
counts, measurement intrusion is kept to a minimum.
To illustrate, let us collect fprof data on a run of an example program called matmul.
First, we will compile matmul with full optimization enabled:
$ /opt/ansic/bin/cc -Aa +O3 -o matmul matmul.c
Now we will have HP Caliper collect performance data for one run of matmul:
$ caliper fprof ./matmul
Once matmul exits, HP Caliper writes a text report to stdout (by default) as shown
in Figure 2-1 “fprof Measurement Report for matmul, with Default Report Output”.
The numbers (which are bold in the PDF version of this guide) are annotations to
explain the report—they are not part of the output you receive. See the list at the end
of the report for the explanations.
Example: Running fprof on a Short Program, with Default Output 29