OpenHarmony性能分析工具之Hiperf
一、hiperf使用
代碼位置 https://gitee.com/openharmony/developtools_hiperf。
1.主命令參數
2.list 命令
列出設備上支持的所有事件名稱。
事件名稱用于 stat 和 record 的 -e 和 -g 參數。
Usage: hiperf list [event type name]
下面列出了設備支持的HW事件,并且會提示哪些事件此設備不支持。
./hiperf list hw
3.stat 命令
監聽指定目標程序,周期性打印性能計數器的值。
Usage: hiperf stat [options] [command [command-args]]
Collect performance counter information of running [command].
下面展示了一個 stats 監聽本進程 在 CPU 0 上 3 秒的性能計數器命令。
./hiperf stat -d 3 -c 0
4.record 命令
采樣指定目標程序,并且將采樣數據保存到指定的文件中(默認為perf.data)。
Usage: hiperf record [options] [command [command-args]]
Collect performance sampling information of running [command].
對全系統所有進程采樣3秒,并且顯示詳細的信息。
./hiperf record -d 3 -a --verbose
二、hiperf使用示例
1.hiperf命令
hiperf record -d 10 -a
默認生成perf.data文件路徑:
/data/local/tmp
2.hdc導出perf.data文件
hdc file recv /data/local/tmp/perf.data %cd%
3.生成符號表
(1)將lib庫:
Z:\OpenHarmony\master\out\rk3568\mingw_x86_64\developtools\hiperf
libhiperf_report.dll
libhiperf_report.lib
拷貝到腳本recv_binary_cache.py的當前目錄的bin\windows\x86_64目錄下。
(2) 將hdc_std.exe文件添加到PATH路徑下。
(3)板子連接電腦,hdc_std shell可以正常使用。
(4) perf.data文件在 recv_binary_cache.py腳本的目錄下。
(5)收集perf.data 里面記錄的相關文件和庫的符號表。
python recv_binary_cache.py -l Z:\OpenHarmony\master\out\rk3568\lib.unstripped Z:\OpenHarmony\master\out\rk3568\exe.unstripped
路徑根據實際使用修改。
4.生成html文件
產生HTML文件,默認的文件名是 hiperf_report.html。
python make_report.py
5.html文件
Chart Statistics界面。
Sample Table界面。
Flame Graph界面。