2024年10月30日 第27讲 Request Latency 极客笔记
本讲是Android Camera性能分析专题的第27讲,我们介绍CameraServer Request Latency,包括如下内容:
资源 | 描述 |
---|---|
在线课程 | 极客笔记在线课程 |
知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
极客笔记圈 |
Request Latency用于衡量HAL执行processBatchCaptureRequests的耗时。
影响:
Request Latency直方图配置
static const int32_t kRequestLatencyBinSize = 40; // in ms
添加Sample的时机
nsecs_t tRequestStart = systemTime(SYSTEM_TIME_MONOTONIC);
submitRequestSuccess = sendRequestsBatch();
nsecs_t tRequestEnd = systemTime(SYSTEM_TIME_MONOTONIC);
mRequestLatency.add(tRequestStart, tRequestEnd);
void CameraLatencyHistogram::add(nsecs_t start, nsecs_t end) {
nsecs_t duration = end - start;
int32_t durationMs = static_cast(duration / 1000000LL);
int32_t binIndex = durationMs / mBinSizeMs;
if (binIndex < 0) {
binIndex = 0;
} else if (binIndex >= mBinCount) {
binIndex = mBinCount-1;
}
mBins[binIndex]++;
mTotalCount++;
mTotoalDuration += duration;
}
打印Log时:
void CameraLatencyHistogram::log(const char* fmt, ...) {
if (mTotalCount == 0) {
return;
}
va_list args;
va_start(args, fmt);
String8 histogramName = String8::formatV(fmt, args);
ALOGI("%s (%" PRId64 ") samples, avg(%.2f ms):", histogramName.string(), mTotalCount, (float)(mTotoalDuration/1e6) / mTotalCount);
va_end(args);
String8 lineBins, lineBinCounts;
formatHistogramText(lineBins, lineBinCounts);
ALOGI("%s", lineBins.c_str());
ALOGI("%s", lineBinCounts.c_str());
}
本文链接:http://so.lmcjl.com/news/16556/