第27讲 request latency -凯发k8旗舰厅

本讲是android camera性能分析专题的第27讲,我们介绍cameraserver request latency,包括如下内容:

  1. request latency是什么
  2. request latency配置
  3. request latency实战
资源 描述
在线课程
知识星球 星球名称:深入浅出android camera
星球id: 17296815
wechat 极客笔记圈

request latency是什么

request latency用于衡量hal执行processbatchcapturerequests的耗时。

影响:

  • 如果该耗时太长,会拉低capturerequest的帧率,需要从hal角度分析

request latency配置

request latency直方图配置

  • 分成10份(默认值), 间隔为40ms
  • static const int32_t krequestlatencybinsize = 40; // in ms

添加sample的时机

  • 在每次调用hal的processcapturerequest接口时,会统计其耗时,然后作为一个sample添加到cameralatencyhistogram

request latency配置

request latency实战

  • 代码讲解
nsecs_t trequeststart = systemtime(system_time_monotonic);
submitrequestsuccess = sendrequestsbatch();
nsecs_t trequestend = systemtime(system_time_monotonic);
mrequestlatency.add(trequeststart, trequestend);
  • 实战演示:在cameralatencyhistogram增加samples总的平均耗时
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());
}

camera课程

python教程

java教程

web教程

数据库教程

图形图像教程

办公软件教程

linux教程

计算机教程

大数据教程

开发工具教程

android camera性能分析

网站地图