← 返回命令列表

Linux command

gprof 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Generate profile report

gprof [program] [gmon.out]

Flat profile only

gprof -p [program]

Call graph only

gprof -q [program]

Suppress static functions

gprof -a [program]

Output to file

gprof [program] > [profile.txt]

说明

gprof analyzes program execution profiles to identify performance bottlenecks. It requires programs compiled with the -pg flag and produces reports showing time spent in each function and call relationships. The tool generates two main reports: a flat profile showing time per function, and a call graph showing function relationships and cumulative times.

参数

-p, --flat-profile
Print flat profile only.
-q, --graph
Print call graph only.
-b, --brief
Suppress explanatory text.
-a, --no-static
Suppress static functions.
-z, --display-unused-functions
Show functions never called.
-c, --static-call-graph
Include static call graph.
-A, --annotated-source
Print annotated source.
-l, --line
Line-by-line profiling.

FAQ

What is the gprof command used for?

gprof analyzes program execution profiles to identify performance bottlenecks. It requires programs compiled with the -pg flag and produces reports showing time spent in each function and call relationships. The tool generates two main reports: a flat profile showing time per function, and a call graph showing function relationships and cumulative times.

How do I run a basic gprof example?

Run `gprof [program] [gmon.out]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p, --flat-profile do in gprof?

Print flat profile only.