本讲是android camera性能分析专题的第34讲,我们介绍perfetto 分析cpu 频率。
更多资源:
资源 | 描述 |
---|---|
在线课程 | |
知识星球 | 星球名称:深入浅出android camera 星球id: 17296815 |
极客笔记圈 |
需要打开scheduling events trace config cpu frequency and idle states。
data_sources: {
config {
name: "linux.process_stats"
target_buffer: 1
process_stats_config {
scan_all_processes_on_start: true
}
}
}
data_sources: {
config {
name: "linux.ftrace"
ftrace_config {
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"
buffer_size_kb: 2048
drain_period_ms: 250
}
}
}
读取ftrace的trace config:
data_sources: {
config {
name: "linux.ftrace"
ftrace_config {
ftrace_events: "power/cpu_frequency"
ftrace_events: "power/cpu_idle"
ftrace_events: "power/suspend_resume"
}
}
}
读取/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
data_sources: {
config {
name: "linux.sys_stats"
sys_stats_config {
cpufreq_period_ms: 1000
}
}
}
perfetto上可以查看每个cpu frequency的变量情况。
注意:在许多情况下,cpu的频率在几秒钟内不会发生变化,如果录制trace的过程中frequency一直没有变化,则不会显示frequency这几行。
perfetto 查看某段slice跑在哪个cpu以及频率:
点击slice,可以看到running on cpu 4,因此该task被调度到cpu 4上运行:
跳到cpu区域,能看到当前cpu4的frequency为1500000mhz
打开linux.system_info data source:
data_sources {
config {
name: "linux.system_info"
}
}
在perfetto中执行如下sql语句查询各cpu的frequency列表
select * from cpu_freq
输出: