2022-11-08 13:47:11 -08:00
|
|
|
# gprof
|
|
|
|
|
|
|
|
> Performance analysis tool for many programming languages.
|
|
|
|
> It profiles the function executions of a program.
|
|
|
|
> More information: <https://ftp.gnu.org/old-gnu/Manuals/gprof-2.9.1/html_mono/gprof.html>.
|
|
|
|
|
2025-01-20 15:53:45 -05:00
|
|
|
- Compile binary to default `a.out` with gprof information and run it to get `gmon.out`:
|
2022-11-08 13:47:11 -08:00
|
|
|
|
2025-01-20 15:53:45 -05:00
|
|
|
`gcc -pg {{program.c}} && ./a.out`
|
2022-11-08 13:47:11 -08:00
|
|
|
|
2025-01-20 15:53:45 -05:00
|
|
|
- Run gprof on default `a.out` and `gmon.out` to obtain profile output:
|
2022-11-08 13:47:11 -08:00
|
|
|
|
|
|
|
`gprof`
|
|
|
|
|
2025-01-20 15:53:45 -05:00
|
|
|
- Run gprof on a named binary:
|
|
|
|
|
|
|
|
`gprof {{path/to/binary}} {{path/to/gmon.out}}`
|
|
|
|
|
2022-11-08 13:47:11 -08:00
|
|
|
- Suppress profile field's description:
|
|
|
|
|
|
|
|
`gprof -b`
|
|
|
|
|
|
|
|
- Display routines that have zero usage:
|
|
|
|
|
|
|
|
`gprof -bz`
|