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