← 返回命令列表

Linux command

perf 命令

文本

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

常用示例

Example

perf stat [command]

Example

sudo perf top

Record

sudo perf record [command]

Example

sudo perf record -p [pid]

Display

sudo perf report

Record

sudo perf record -g [command]

Example

perf list

说明

perf is the official Linux kernel profiling tool. It provides access to hardware performance counters, tracepoints, and software performance events. It's essential for identifying performance bottlenecks in applications and the kernel. The tool can measure CPU cycles, cache misses, branch mispredictions, and many other low-level events. It supports both sampling-based profiling and event counting.

参数

-p, --pid _pid_
Profile existing process by PID
-e, --event _event_
Select specific events to measure
-g, --call-graph
Enable call-graph (stack chain/backtrace) recording
-a, --all-cpus
System-wide collection from all CPUs
-F _freq_, --freq _freq_
Profile at specified frequency (samples per second)
-o _file_, --output _file_
Output file name
-c _count_, --count _count_
Collect a sample after every _count_ events

FAQ

What is the perf command used for?

perf is the official Linux kernel profiling tool. It provides access to hardware performance counters, tracepoints, and software performance events. It's essential for identifying performance bottlenecks in applications and the kernel. The tool can measure CPU cycles, cache misses, branch mispredictions, and many other low-level events. It supports both sampling-based profiling and event counting.

How do I run a basic perf example?

Run `perf stat [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -p, --pid _pid_ do in perf?

Profile existing process by PID