perf是一款集成于Linux内核(2.6+)性能分析工具。这里所用平台:RHEL6 64bit
安装:
perf是随着Linux内核(2.6+)代码一起发布的,安装很简单,默认安装没有激活TUI(text-based user interface)选项的,如果要激活TUI选项,前提是要安装newt-devel RPM包。
[root@rhel6164 ~]# rpm -qa | grep newt-devel
newt-devel-0.52.11-2.el6.x86_64 #如果要激活perf的TUI选项,就要提前安装newt-devel包
[root@rhel6164 ~]# cd linux-3.10.34/tools/perf/ #进入内核perf目录
[root@rhel6164 perf]# make #直接编译perf
[root@rhel6164 perf]# make install DESTDIR="installation_path" #不用默认安装路径,指定安装路径到“installation_path"
[root@rhel6164 perf]# perf --version
perf version 3.10.34
使用:
直接在输入perf就可以看到perf的使用说明
[root@rhel6164 ~]# perf
usage: perf [--version] [--help] COMMAND [ARGS]
The most commonly used perf commands are:
annotate Read perf.data (created by perf record) and display annotated code
archive Create archive with object files with build-ids found in perf.data file
bench General framework for benchmark suites
buildid-cache Manage build-id cache.
buildid-list List the buildids in a perf.data file
diff Read two perf.data files and display the differential profile
evlist List the event names in a perf.data file
inject Filter to augment the events stream with additional information
kmem Tool to trace/measure kernel memory(slab) properties
kvm Tool to trace/measure kvm guest os
list List all symbolic event types
lock Analyze lock events
mem Profile memory accesses
record Run a command and record its profile into perf.data
report Read perf.data (created by perf record) and display the profile
sched Tool to trace/measure scheduler properties (latencies)
script Read perf.data (created by perf record) and display trace output
stat Run a command and gather performance counter statistics
test Runs sanity tests.
timechart Tool to visualize total system behavior during a workload
top System profiling tool.
trace strace inspired tool
probe Define new dynamic tracepoints
See 'perf help COMMAND' for more information on a specific command.