Navigation

    全志在线开发者论坛

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • 在线文档
    • 社区主页

    【FAQ】全志R329 Tina中使用如何使用perf分析CPU使用率?

    其它全志芯片讨论区
    r329 r328 r818 faq 技术支持
    1
    1
    209
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • q1215200171
      budbool LV 8 last edited by q1215200171

      perf简介

      Perf是是内置于Linux内核源码树中的性能剖析(profiling)工具。

      • 不仅可以用于应用程序的性能统计分析,还可以用于内核的性能统计和分析。
      • 它基于事件采样原理,以性能事件为基础,支持针对处理器相关性能指标与操作系统相关性能指标的性能剖析。
      • 常用于性能瓶颈的查找与热点代码的定位。

      Tina上开启perf功能

      删除out目录,开启如下Tina与内核的相关选项,重新编译。客户的程序不能strip。

      52922898c4824c2c9899e4f345523674.jfif

      如果客户应用程序没有嵌入到Tina一起编译,建议客户检查相关编译选项,主要是浮点、neon、优化等选项,如”-Os -march=armv7-a -mtune=cortex-a7 -mfpu=neon -mfloat-abi=hard“等。

      使用perf工具分析CPU使用率

      • 设备端先采集:
        ① perf record -e cpu-clock -g -p --> 采集指定PID进程的cpu使用情况,采集的数据存放到当前目录下的perf.data文件中
        perf record -e cpu-clock -g -a --> 采集指定整个系统的cpu使用情况,采集的数据存放到当前目录下的perf.data文件中
        ② perf script -i perf.data > /tmp/perf.data.txt --> 解析perf.data转换为文本文档
        ③ perf report --> 设备端解析当前路径下perf.data文件生成报告

      • PC端借助flamegraph生成火焰图(也可以直接在设备端执行perf report来分析):
        ① adb pull /tmp/perf.data.txt .
        ② ./stackcollapse-perf.pl perf.data.txt > perf.data.fold --> 将文本文档中的符号进行折叠
        ③ ./flamegraph.pl perf.data.fold > perf.svg --> 生成svg图

      • PC端(ubuntu)工具如附件FlameGraph.tar.xz所示。

      火焰图说明

      生成的火焰图类似下图。其中x轴表示抽样数,如有一个函数在x轴上的长度越长,表明抽样的次数越多,则执行时间越长,占用cpu越多。y轴表示调用栈,每个函数占据一层,层数(火焰)越高,表明调用栈越深。

      797c3e02b9ee4140ba67f4f1ed4c25a8.jfif

      附件:FlameGraph.tar.xz

      1 Reply Last reply Reply Quote Share 0
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • Referenced by  q1215200171 q1215200171 
      • 1 / 1
      • First post
        Last post

      Copyright © 2022 深圳全志在线有限公司 粤ICP备2021084185号 粤公网安备44030502007680号

      行为准则 | 用户协议 | 隐私权政策