# GNU gprof

## Table of Contents

- Profiling a Program: Where Does It Spend Its Time?
- 1 Introduction to Profiling
- 2 Compiling a Program for Profiling
- 3 Executing the Program
- 4 `gprof` Command Summary
  - 4.1 Output Options
  - 4.2 Analysis Options
  - 4.3 Miscellaneous Options
  - 4.4 Deprecated Options
  - 4.5 Symspecs
- 5 Interpreting `gprof`'s Output
  - 5.1 The Flat Profile
  - 5.2 The Call Graph
    - 5.2.1 The Primary Line
    - 5.2.2 Lines for a Function's Callers
    - 5.2.3 Lines for a Function's Subroutines
    - 5.2.4 How Mutually Recursive Functions Are Described
  - 5.3 Line-by-line Profiling
  - 5.4 The Annotated Source Listing
- 6 Inaccuracy of `gprof` Output
  - 6.1 Statistical Sampling Error
  - 6.2 Estimating `children` Times
- 7 Answers to Common Questions
- 8 Incompatibilities with Unix `gprof`
- 9 Details of Profiling
  - 9.1 Implementation of Profiling
  - 9.2 Profiling Data File Format
    - 9.2.1 Histogram Records
    - 9.2.2 Call-Graph Records
    - 9.2.3 Basic-Block Execution Count Records
  - 9.3 `gprof`'s Internal Operation
  - 9.4 Debugging `gprof`
- Appendix A GNU Free Documentation License

Next: Introduction, Up: (dir)

## Profiling a Program: Where Does It Spend Its Time?

This manual describes the gnu profiler, `gprof`, and how you can use it to determine which parts of a program are taking most of the execution time. We assume that you know how to write, compile, and execute programs. gnu `gprof` was written by Jay Fenlason.

This manual is for `gprof` (GNU Binutils) version 2.23.1.

This document is distributed under the terms of the GNU Free Documentation License version 1.3. A copy of the license is included in the section entitled “GNU Free Documentation License”.