当前位置:网站首页>AOSP CameraLatencyHistogram的原理与使用
AOSP CameraLatencyHistogram的原理与使用
2022-08-03 22:39:00 【InfoQ】
CameraLatencyHistogram是什么
源码解析
头文件定义
- mBinSizeMs 记录的是当前记录表的标准时间,比如预设一次request的标准时长为40ms
- mBinCount 记录的是直方图的等级划分数量,通常默认是10个等级
- mBins 记录的是直方图各个等级的数量
- mTotalCount 记录的是直方图的统计数量总数
类初始化
增加一个数据/清空所有数据
dump/log以及内部处理函数formatHistogramText
- 先dump数据的行头,标识dump时的记录数据量;
- 然后将直方图数据构造成字符串;
- 将直方图数据写入到对应的fd文件中。
- 先打印耗时的时间段,如33ms/66ms/99ms,最大值打印为inf (max ms)
- 然后打印每一个段数据占总数据量的百分比
100.0*mBins[i]/mTotalCount
- 最后打印一个%号。
使用该工具的位置
mDequeueBufferLatency:dequeue buffer的时延,5ms
///frameworks/av/services/camera/libcameraservice/device3/Camera3OutputStream.h
//dequebuffer默认耗时5ms,进行记录
static const int32_t kDequeueLatencyBinSize = 5; // in ms C
ameraLatencyHistogram mDequeueBufferLatency;
status_t Camera3OutputStream::getBuffersLocked(std::vector<OutstandingBuffer>* outBuffers) {
...
nsecs_t dequeueStart = systemTime(SYSTEM_TIME_MONOTONIC);
res = consumer->dequeueBuffers(&buffers);
nsecs_t dequeueEnd = systemTime(SYSTEM_TIME_MONOTONIC);
mDequeueBufferLatency.add(dequeueStart, dequeueEnd);
...
}
mBufferLimitLatency:buffer signal时延,33ms
///frameworks/av/services/camera/libcameraservice/device3/Camera3Stream.h
// Latency histogram of the wait time for handout buffer count to drop below
// max_buffers.
static const int32_t kBufferLimitLatencyBinSize = 33; //in ms
CameraLatencyHistogram mBufferLimitLatency;
status_t Camera3Stream::getBuffer(camera_stream_buffer *buffer, nsecs_t waitBufferTimeout, const std::vector<size_t>& surface_ids) {
...
nsecs_t waitStart = systemTime(SYSTEM_TIME_MONOTONIC);
if (waitBufferTimeout < kWaitForBufferDuration) {
waitBufferTimeout = kWaitForBufferDuration;
}
res = mOutputBufferReturnedSignal.waitRelative(mLock, waitBufferTimeout);
nsecs_t waitEnd = systemTime(SYSTEM_TIME_MONOTONIC);
mBufferLimitLatency.add(waitStart, waitEnd);
...
}
mRequestLatency:request执行的时延,40ms
///frameworks/av/services/camera/libcameraservice/device3/Camera3Device.h
//记录request的时延,默认一帧request时长40ms
static const int32_t kRequestLatencyBinSize = 40; // in ms
CameraLatencyHistogram mRequestLatency;
bool Camera3Device::RequestThread::threadLoop() {
...
bool submitRequestSuccess = false;
nsecs_t tRequestStart = systemTime(SYSTEM_TIME_MONOTONIC);
submitRequestSuccess = sendRequestsBatch();
nsecs_t tRequestEnd = systemTime(SYSTEM_TIME_MONOTONIC);
mRequestLatency.add(tRequestStart, tRequestEnd);
...
}
具体使用
边栏推荐
- log4j-slf4j-impl cannot be present with log4j-to-slf4j
- With 4 years of work experience, the 5 communication methods between multi-threads can't be said, can you believe it?
- 483. Smallest Good Base
- HDU 5655 CA Loves Stick
- "Digital Economy Panorama White Paper" Financial Digital User Chapter released!
- [N1CTF 2018]eating_cms
- [N1CTF 2018] eating_cms
- Flutter 桌面探索 | 自定义可拖拽导航栏
- 伴随着元宇宙、web3.0等概念的兴起,数字人、数字场景等诸多数字化的形态开始出现
- What is memoization and what is it good for?
猜你喜欢
投资性大于游戏性 NFT游戏到底是不是门好生意
藏宝计划TreasureProject(TPC)系统模式开发技术原理
【day6】类与对象、封装、构造方法
[N1CTF 2018]eating_cms
Bytebase database schema change management tool
Gains double award | know micro easily won the "2021 China digital twin solution suppliers in excellence" "made in China's smart excellent recommended products" double award!
Conditional Statements for Shell Programming
Summary bug 】 【 Elipse garbled solution project code in Chinese!
【开源框架】国内首个通用云计算框架,任意程序都可做成云计算。
电商秒杀系统
随机推荐
21天打卡挑战学习MySQL——《Window下安装MySql》第一周 第三篇
Conditional Statements for Shell Programming
Golang第一章:入门
网络基础学习系列四(网络层,数据链路层和一些其他重要协议或技术)
UVa 10003 - Cutting Sticks (White Book, Interval DP)
override学习(父类和子类)
目标检测的国内外研究现状
图的基础概念
Research status of target detection at home and abroad
472. Concatenated Words
Makefile
488. Zuma Game
[b01lers2020]Life on Mars
Shell编程的条件语句
Recognized by International Authorities | Yunzhuang Technology was selected in "RPA Global Market Pattern Report, Q3 2022"
电商秒杀系统
举一个 web worker 的例子
Embedded Systems: GPIO
2022-08-03 oracle执行慢SQL-Q17对比
老板:公司系统太多,能不能实现账号互通?