2024年10月31日 第42讲 Perfetto 自动化之Camera启动性能自动化分析 极客笔记
本讲是Android Camera性能分析专题的第42讲,我们介Perfetto 自动化之Camera启动性能自动化分析。
更多资源:
资源 | 描述 |
---|---|
在线课程 | 极客笔记在线课程 |
知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
极客笔记圈 |
模块 | 开始点 | 结束点 |
---|---|---|
App | 点击Camera App Icon | 开始调用connectDevice |
HAL | 开始调用connectDevice | 调用connectDevice结束 |
App | 调用connectDevice结束 | 开始调用endConfigure |
HAL | 开始调用endConfigure | 调用endConfigure结束 |
App | 调用endConfigure结束 | 调用submitRequestList |
HAL | 调用submitRequestList | CameraServer收到第一帧 |
代码:
from perfetto.trace_processor import TraceProcessor
from perfetto.trace_processor import TraceProcessorConfig
tp = TraceProcessor(trace='geekcamera2_camera_launch.trace',
config=TraceProcessorConfig(
bin_path=r'trace_processor_shell_v3.7.exe',
verbose=False
))
### click up
click_app_icon = tp.query('SELECT (slice.ts+slice.dur)/1e6 '
'FROM slice '
'WHERE ts <(SELECT ts FROM slice WHERE name == "connectDevice" LIMIT 1) '
'AND name like "%deliverInputEvent%" '
'ORDER BY ts DESC '
'LIMIT 1')
click_app_icon_ms = click_app_icon.as_pandas_dataframe().values[0][0]
### Connect Device
open_session = tp.query('SELECT (slice.ts/1e6), (slice.dur/1e6) '
'FROM slice '
'WHERE slice.name like "%CameraHal::openSession%"')
open_session_df = open_session.as_pandas_dataframe()
open_session_begin_ms = open_session_df.values[0][0]
open_session_duration_ms = open_session_df.values[0][1]
### beginConfigure
begin_configure = tp.query('SELECT (slice.ts/1e6) '
'FROM slice '
'WHERE slice.name like "%beginConfigure%" '
'LIMIT 1')
begin_configure_df = begin_configure.as_pandas_dataframe()
begin_configure_ms = begin_configure_df.values[0][0]
### endConfigure
end_configure = tp.query('SELECT (slice.ts/1e6), (slice.dur/1e6) '
'FROM slice '
'WHERE slice.name like "%endConfigure%" '
'LIMIT 1')
end_configure_df = end_configure.as_pandas_dataframe()
end_configure_begin_ms = end_configure_df.values[0][0]
end_configure_duration_ms = end_configure_df.values[0][1]
### submitRequestList
submit_request_list = tp.query('SELECT (slice.ts/1e6) '
'FROM slice '
'WHERE slice.name like "%submitRequestList%" '
'ORDER BY slice.ts ASC '
'LIMIT 1')
submit_request_list_df = submit_request_list.as_pandas_dataframe()
submit_request_list_begin_ms = submit_request_list_df.values[0][0]
### CameraServer queue first frame
first_full_buffer = tp.query('SELECT (slice.ts/1e6), (slice.dur/1e6) '
'FROM slice '
'WHERE slice.name like "%first full buffer%"')
first_full_buffer_df = first_full_buffer.as_pandas_dataframe()
first_full_buffer_queued_ms = first_full_buffer_df.values[0][0] + first_full_buffer_df.values[0][1]
### print results
print("Total Launch time:" + str(round((first_full_buffer_queued_ms - click_app_icon_ms), 2)) + " ms, break down as following:")
print(" [App] Click --> CameraHal::openSession: " +
str(round((open_session_begin_ms - click_app_icon_ms), 2)) + " ms")
print(" [HAL] CameraHal::openSession: " +
str(round((open_session_duration_ms), 2)) + " ms")
print(" [App] CameraHal::openSession --> beginConfigure: " +
str(round((begin_configure_ms - open_session_duration_ms - open_session_begin_ms), 2)) + " ms")
print(" [HAL] beginConfigure --> endConfigure: " +
str(round((end_configure_begin_ms + end_configure_duration_ms - begin_configure_ms), 2)) + " ms")
print(" [App] endConfigure --> submitRequestList: " +
str(round((submit_request_list_begin_ms - end_configure_begin_ms - end_configure_duration_ms), 2)) + " ms")
print(" [HAL] submitRequestList --> Stream x: first full buffer: " +
str(round((first_full_buffer_queued_ms - submit_request_list_begin_ms), 2)) + " ms")
输出:
本文链接:http://so.lmcjl.com/news/16678/