1、Smartperf_host工具下载

推荐使用Smarperf_host工具抓取并打开Trace,打开下方网站,下载发行版;

https://gitee.com/openharmony/developtools_smartperf_host?_from=gitee_search

解压后,双击main.exe,会部署打开一个Smartperf_Host工具分析网站。

 

2、带火焰图的Trace抓取方法 

 

 

上述准备工作做好之后点击Trace command复制抓取Trace命令

 

3、Trace抓取HiSmartPerf网站分析

 

连接OH设备打开hdc调试复制命令粘贴进去

 

hiprofiler_cmd \
  -c - \
  -o /data/local/tmp/hiprofiler_data.htrace \
  -t 30 \
  -s \
  -k \
<<CONFIG
 request_id: 1
 session_config {
  buffers {
   pages: 16384
  }
 }
 plugin_configs {
  plugin_name: "ftrace-plugin"
  sample_interval: 1000
  config_data {
   ftrace_events: "sched/sched_switch"
   ftrace_events: "power/suspend_resume"
   ftrace_events: "sched/sched_wakeup"
   ftrace_events: "sched/sched_wakeup_new"
   ftrace_events: "sched/sched_waking"
   ftrace_events: "sched/sched_process_exit"
   ftrace_events: "sched/sched_process_free"
   ftrace_events: "task/task_newtask"
   ftrace_events: "task/task_rename"
   ftrace_events: "power/cpu_frequency"
   ftrace_events: "power/cpu_idle"
   hitrace_categories: "ability"
   hitrace_categories: "ace"
   hitrace_categories: "app"
   hitrace_categories: "ark"
   hitrace_categories: "binder"
   hitrace_categories: "disk"
   hitrace_categories: "freq"
   hitrace_categories: "graphic"
   hitrace_categories: "idle"
   hitrace_categories: "irq"
   hitrace_categories: "memreclaim"
   hitrace_categories: "mmc"
   hitrace_categories: "multimodalinput"
   hitrace_categories: "notification"
   hitrace_categories: "ohos"
   hitrace_categories: "pagecache"
   hitrace_categories: "rpc"
   hitrace_categories: "sched"
   hitrace_categories: "sync"
   hitrace_categories: "window"
   hitrace_categories: "workq"
   hitrace_categories: "zaudio"
   hitrace_categories: "zcamera"
   hitrace_categories: "zimage"
   hitrace_categories: "zmedia"
   buffer_size_kb: 204800
   flush_interval_ms: 1000
   flush_threshold_kb: 4096
   parse_ksyms: true
   clock: "boot"
   trace_period_ms: 200
   debug_on: false
  }
 }
 plugin_configs {
  plugin_name: "hiperf-plugin"
  sample_interval: 5000
  config_data {
   is_root: false
   outfile_name: "/data/local/tmp/perf.data"
   record_args: "-f 1000 -a --exclude-hiperf --cpu-limit 100 -e hw-cpu-cycles --call-stack dwarf --clockid monotonic -m 256"
  }
 }
CONFIG

 

回车执行OH设备同步操作需要抓取场景命令执行完毕会在 /data/local/tmp 生成 .htrace 文件

使用hdc file recv /data/local/tmp/hiperfiler_data.htrace 本地地址命令.htrace文件导出本地环境使用HiSmartPerf网站打开

我们可以看到Hiperf(ALL)trace点开可以框选一段时间查看火焰图以及CPU使用信息

 

Logo

社区规范:仅讨论OpenHarmony相关问题。

更多推荐