檢查當前環境核心的版本,執行如下命令:
uname -a
輸出資訊如下:
Linux jackie-ubuntu 5.4.0-26-generic #30-Ubuntu SMP Mon Apr 20 16:58:30 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
安裝perf
工具,執行如下命令:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt-get install linux-tools-common linux-tools-$(uname -r)
檢視perf
工具的版本,執行如下命令:
perf --version
輸出資訊如下:
perf version 5.4.30
檢視perf
命令的使用幫助,輸出資訊如下:
usage: perf [--version] [--help] [OPTIONS] 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
c2c Shared Data C2C/HITM Analyzer.
config Get and set variables in a configuration file.
data Data file related processing
diff Read perf.data files and display the differential profile
evlist List the event names in a perf.data file
ftrace simple wrapper for kernel's ftrace functionality
inject Filter to augment the events stream with additional information
kallsyms Searches running kernel for symbols
kmem Tool to trace/measure kernel memory 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.
version display the version of perf binary
probe Define new dynamic tracepoints
trace strace inspired tool
See 'perf help COMMAND' for more information on a specific command.
參考資料
- ubuntu中安裝perf
- 學會使用perf效能分析工具(含移植到arm-linux開發板)
- 手把手教你係統級效能分析工具perf的介紹與使用(超詳細)
- 【Ubuntu】 Perf工具的使用
- perf效能分析工具使用分享
- Perf -- Linux下的系統效能調優工具
- Linux kernel profiling with perf
- Perfcounters added to the mainline
- Performance Counters on Linux The New Tools