第44讲 Perfetto 自动化之Camera拍照性能自动化分析

本讲是Android Camera性能分析专题的第44讲,我们介Perfetto 自动化之Camera拍照性能自动化分析

更多资源:

资源 描述
在线课程 极客笔记在线课程
知识星球 星球名称:深入浅出Android Camera
星球ID: 17296815
Wechat 极客笔记圈

Camera 拍照性能拆解

这里我们只拆解从单击拍照按钮到收到拍照的图片,后续App的流程大家可以自己完善。

  • 点击拍照->下拍照Request
  • 处理完拍照Request

Camera 拍照时间自动化分析

代码如下:

#!/usr/bin/env python3
from perfetto.trace_processor import TraceProcessor
from perfetto.trace_processor import TraceProcessorConfig

tp = TraceProcessor(trace=r'capture.perfetto-trace', config=TraceProcessorConfig(
    bin_path=r'trace_processor_shell_v3.7.exe',
    verbose=False))

### Click shutter button icon
geekcamera_click_sql = """SELECT ts/1e6, dur/1e6 FROM
                slice
                JOIN process_track ON slice.track_id = process_track.id
                JOIN process USING(upid)
                WHERE slice.name='deliverInputEvent' AND process.name like '%geekcamera%'
                ORDER BY slice.ts DESC
                LIMIT 1"""
click_app_icon = tp.query(geekcamera_click_sql)
click_app_icon_ms = click_app_icon.as_pandas_dataframe().values[0][0]

### capture submitrequest
still_capture = tp.query("""SELECT ts/1e6, dur/1e6 FROM
                            slice
                            WHERE name = "still capture" LIMIT 1""").as_pandas_dataframe()
still_capture_begin_ms = still_capture.values[0][0]
still_capture_dur_ms = still_capture.values[0][1]

print("Total Camera Capture time:" + str(round((still_capture_begin_ms + still_capture_dur_ms - click_app_icon_ms), 2)) + " ms, break down as following:")
print("    [App] Click                     -->                  submitRequestList: " +
      str(round((still_capture_begin_ms - click_app_icon_ms), 2)) + " ms")
print("    [HAL] submitRequestList         -->                  capture end: " +
      str(round((still_capture_dur_ms), 2)) + " ms")

输出:

Camera 拍照时间自动化分析

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程

Android Camera性能分析