perfetto 常用查询

### 进程中各线程优先级查询
“`
select process.name as process_name,
process.pid as process_pid,
thread.name as thread_name,
thread.tid,
sched.priority as priority
from sched
inner join thread using(utid)
inner join process using(upid)
where process.pid in(28058,28011) /*输入多个参数*/
group by thread.tid
order by priority
“`
### 进程在各cpu运行时间
“`
select process.name as process_name,
process.pid as process_pid,
sched.cpu,
sum(sched.dur)/1e6
from sched
inner join thread using(utid)
inner join process using(upid)
where process.pid in(28058) /*输入进程pid参数*/
and sched.ts>= 16850396073998 and sched.ts <= 16851833181075/*输入开始与结束时间 eg:16850396073998 开始时间 16851833181075 结束时间*/ group by sched.cpu order by sched.cpu ``` ### 各线程D状态block_function 相关方法统计 ``` select * from ( select process.name as process_name, process.pid as process_pid, thread.name as thread_name, thread.tid as thread_tid, blocked_function, sum(dur)/1e3 as dur_time_ms from thread_state inner join thread using(utid) inner join process using(upid) where thread.tid in (5593,5594,5595,5596,5597,5598,5599,5600) /*顺序写线程:5576 随机读写线程:5593,5594,5595,5596,5597,5598,5599,5600*/ and blocked_function not null group by blocked_function ) order by dur_time_ms desc ``` ### 统计线程在一段时间内各cpu运行时间 ``` select thread.name as thread_name, thread.tid as thread_tid, sched.cpu as run_cpu_idx , sum(dur)/1e6 as run_cpu_duration_ms from sched inner join thread using (utid) where thread.tid = 13087 and sched.ts >= (113286094474357 -1) and sched.ts <= ( 113286094474357 + 347372616) group by thread.tid,sched.cpu ``` ### 统计进程在一段时间内各cpu运行时间 select process.name as process_name, sched.cpu as run_cpu_idx , sum(dur)/1e6 as run_cpu_duration_ms from sched inner join thread using (utid) inner join process using (upid) where process.pid = 13087 and sched.ts >= (113286094474357 -1) and sched.ts <= ( 113286094474357 + 347372616) group by sched.cpu

发表评论