Profiling GPU Rendering Walkthrough

  This walkthrough shows how to use Profile GPU Rendering on your mobile device.

  Profile GPU Rendering gives you a quick visual representation of how much time it takes to render the frames of a UI window relative to the 16-ms-per-frame benchmark.

 可以查看基于每帧16ms这个参考点,ui所用时间是否正常。

  What it's good for:

  • Quickly seeing how a UI window performs against the 16-ms-per-frame target.
  • Identifying whether any part of the rendering pipeline stands out in using processing time.
  • Looking for spikes in frame rendering time associated with user or program actions.

2.Prerequisites

3.Working with Profile GPU Rendering 开启Profile GPU Rendering 的方法

    1. On your mobile device, go to Settings >Developer Options.
    2. In the Monitoring section, select Profile GPU Rendering.
    3. In the Profile GPU Rendering popup, choose On screen as bars to overlay the graphs on the screen of your mobile device.
    4. Go to the app that you want to profile.

          

          Figure 1. Turning on Profile GPU Rendering.

      5.1.1中文版的图正如下:它有两个选项,一个是直接在屏幕上显示,一个是显示在命令行中显示。

        

          Figure5.中文版设置界面

4.What you see

    • For each visible application, the tool displays a graph.
    • The horizontal axis shows time elapsing, and the vertical axis time per frame in milliseconds.
    • As you interact with your application, vertical bars show up on your screen, appearing from left to right, graphing frame performance over time.
    • Each vertical bar represents one frame of rendering. The taller the bar, the longer it took to render.
    • The green line marks the 16 millisecond target. Every time a frame crosses the green line, your app is missing a frame, and your users may see this as stuttering images.

      

        Figure 2. Screen when Profile GPU Rendering is on.

5.The Profile GPU Rendering Graph

  

    Figure 3. Enlarged Annotated Profile GPU Rendering graph.

  

    Figure6.示例

  In this enlarged image of the Profile GPU Rending graph you can see the colored sections of the graph, and what phase of the rendering pipeline each color represents.

 开启「GPU呈现模式分析」之后,运行目标程序时,会上屏幕上产生图表,如上图。其中不同颜色代表的含义:
  • The green line represents 16 milliseconds. To achieve 60 frames per second, the vertical bar for each frame needs to stay below this 16 ms mark. Any time a bar pushes above this line, there may be pauses in the animations.

    为了保证每秒能绘60帧,每帧应该保持低于16 ms。上图中的绿色横线是一条基线,高于它的说明有问题。
  • Each bar has a blue, purple (only for Android version 4.0 and higher), red, and orange component.
  • The blue section of the bar represents the time used to create and update the View's display lists. If this part of the bar is tall, there may be a lot of custom view drawing, or a lot of work in onDraw methods.
    蓝色竖线 代表创建、更新view的时间,如果它高于基线,说有很多个自定义的view在绘制、更新或者某个onDraw方法中有大量工作。
  • Android 4.0 and higher: The purple section of the bar represents the time spent transferring resources to the render thread.
    紫色坚线 代表资源转移到绘制线程消耗的时间。
  • The red section of the bar represents the time spent by Android's 2D renderer issuing commands to OpenGL to draw and redraw display lists. The height of this bar is directly proportional to the sum of the time it takes each display list to execute—more display lists equals a taller red bar.
    红色竖线 代表 Android 2D 引擎把绘制指令传给 OpenGL 模块消耗的时间。
  • The orange section of the bar represents the time the CPU is waiting for the GPU to finish its work. If this bar gets tall, it means the app is doing too much work on the GPU.
    一般GPU的指令从CPU传来,如果GPU队列満了,CPU就要等待。
    橙色竖线 代表CPU等待GPU完成工作的时间,它过高,说明GPU有大量的工作。注意,是CPU等待GPU。

  Note: While this tool is named Profile GPU Rendering, all monitored processes actually occur in the CPU. Rendering happens by submitting commands to the GPU, and the GPU renders the screen asynchronously. In certain situations, the GPU can have too much work to do, and your CPU will have to wait before it can submit new commands. When this happens, you'll see spikes in the Process (orange bar) and Execute (red bar) stages, and the command submission will block until more room is made on the GPU command queue.

6. adb shell dumpsys gfxinfo 命令

  这个命令就是Figure5中的第2个选项,下面是示例:

6.1 运行目标程序一段时间:

6.2 运行命令,查看它有系统信息:

$ adb shell dumpsys gfxinfo com.e.weixin

得到如下输出:可以把这些数据复制到Excel表格中,来显示一个累积柱状图。

Applications Graphics Acceleration Info:
Uptime: 4701875 Realtime: 12789537 ** Graphics info for pid 12328 [com.e.weixin] ** Recent DisplayList operations
DrawPatch
DrawPatch
DrawPatch
DrawPatch
DrawPatch
DrawDisplayList
Save
ClipRect
DrawDisplayList
DrawDisplayList
DrawDisplayList
RestoreToCount
DrawDisplayList
Save
ClipRect
DrawDisplayList
DrawDisplayList
DrawDisplayList
RestoreToCount
DrawDisplayList
Save
ClipRect
DrawDisplayList
DrawDisplayList
DrawDisplayList
RestoreToCount
DrawDisplayList
Save
ClipRect
DrawDisplayList
DrawDisplayList
DrawDisplayList
RestoreToCount
DrawDisplayList
Save
ClipRect
DrawDisplayList
DrawDisplayList
DrawDisplayList
RestoreToCount
DrawDisplayList
Save
ClipRect
DrawDisplayList
DrawDisplayList
DrawDisplayList
RestoreToCount
DrawDisplayList
DrawDisplayList
DrawPatch Caches:
Current memory usage / total memory usage (bytes):
TextureCache 10435956 / 25165824
LayerCache 0 / 16777216
GradientCache 0 / 524288
PathCache 930 / 4194304
CircleShapeCache 0 / 1048576
OvalShapeCache 0 / 1048576
RoundRectShapeCache 0 / 1048576
RectShapeCache 0 / 1048576
ArcShapeCache 0 / 1048576
TextDropShadowCache 0 / 2097152
FontRenderer 0 262144 / 262144
FontRenderer 1 262144 / 262144
FontRenderer 2 262144 / 262144
Other:
FboCache 0 / 16
PatchCache 3 / 512
Total memory usage:
11223318 bytes, 10.70 MB Profile data in ms: com.e.weixin/com.e.weixin.main.presenter.MainActivity/android.view.ViewRootImpl@422ce8a8
Draw Process Execute
2.67 2.35   1.72
8.87 2.59   1.77
1.97 1.45   7.42
1.91 1.56   7.87
3.57 0.83   4.38
2.88 1.71   3.76
2.63 0.78   4.96
3.57 0.84   3.84
2.10 0.80   5.89
1.77 0.81   4.58
2.61 1.41   2.10
2.90 1.65   1.42
3.50 0.84   1.49
4.58 0.84   1.55
4.24 0.85   1.48
3.98 0.85   2.91
0.76 1.95   1.75
13.61 36.21   1.98
2.33 1.69   1.02
4.74 2.51   1.53
0.25 2.41   1.22
9.61 13.62   1.49
0.37 2.62   1.25
9.09 11.78   1.89
1.53 1.59   0.90
2.93 2.76   1.11
0.27 1.66   1.38
2.65 1.59   3.88
0.26 1.65   1.68
3.20 2.20   1.03
0.76 2.52   1.85
1.35 2.07   1.37
2.38 0.73   1.49
1.98 0.67   1.36
2.39 1.59   2.10
3.78 4.09   1.90
3.89 0.98   11.62
1.91 0.84   13.99
2.10 0.62   12.38
1.57 0.65   12.04
3.16 0.68   11.16
2.20 0.69   12.04
2.60 1.02   11.25
2.48 0.67   11.29
2.12 0.88   11.31
2.27 0.69   11.21 View hierarchy: com.e.weixin/com.e.weixin.main.presenter.MainActivity/android.view.ViewRootImpl@422ce8a8
181 views, 12.45 kB of display lists, 50 frames rendered Total ViewRootImpl: 1
Total Views: 181
Total DisplayList: 12.45 kB

注意 “Profile data in ms”的区域

  每列数据显示了渲染每一帧需要的时间:

  1. Draw 是在Java中创建显示列表所需要的时间。这个值显示了运行绘图函数用了多长时间,比如View.onDraw(Canvas)。
  2. Process 是Android 2D引擎渲染显示列表所需要的时间。在界面中View数目越多,则有越多的绘制命令需要执行。
  3. Execute 是把一帧数据送到屏幕上排版显示的时间,这个时间通常比较小。

屏幕上显示的每一帧都要经过3步:java创建绘制列表,渲染引擎显示列表,把每一帧送到屏幕上排版显示。

6.3 初步分析

  要流畅的运行60帧/秒, 则需要每帧的处理时间不超过16ms。如上图中有个36.21 ,如果多个超过16ms,那么说明有严重问题。

Android 性能优化(21)*性能工具之「GPU呈现模式分析」Profiling GPU Rendering Walkthrough:分析View显示是否超标的更多相关文章

  1. Android开发者选项——Gpu呈现模式分析

    对于Android用户来说,无论你用的什么品牌的手机,在开发者选项中都能发现“玄学曲线”的开关,之所以称其为玄学曲线,还是因为它被很多网友用于测试一个说不清道不明的东西——流畅度.到底多流畅才叫流畅, ...

  2. 浅谈AndroidGPU过度绘制、GPU呈现模式分析及相关优化

    在真机设备下有一个开发者选项,这个大家都知道,我们最常用的就打开'USB调试'功能,方便真机调试. 在这开发者选项中还有个选项,'调试GPU过度绘制' 这里选择第二个选项'显示过度绘制区域' 可以看到 ...

  3. Android开发学习之路--性能优化之常用工具

      android性能优化相关的开发工具有很多很多种,这里对如下六个工具做个简单的使用介绍,主要有Android开发者选项,分析具体耗时的Trace view,布局复杂度工具Hierarchy Vie ...

  4. Android 性能优化 五 性能分析工具dumpsys的使用

    Android提供的dumpsys工具能够用于查看感兴趣的系统服务信息与状态,手机连接电脑后能够直接命令行运行adb shell dumpsys 查看全部支持的Service可是这样输出的太多,能够通 ...

  5. MYSQL之性能优化 ----MySQL性能优化必备25条

    今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我 们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数 ...

  6. 性能优化 | JVM性能调优篇——来自阿里P7的经验总结

    VM 调优概述: 性能定义: 吞吐量 - 指不考虑 GC 引起的停顿时间或内存消耗,垃圾收集器能支撑应用达到的最高性能指标. 延迟 - 其度量标准是缩短由于垃圾啊收集引起的停顿时间或者完全消除因垃圾收 ...

  7. 前端性能优化jQuery性能优化

    一.使用合适的选择器 $("#id"); 1.使用id来定位DOM元素无疑是最佳提高性能的方式,因为jQuery底层将直接调用本地方法document.getElementById ...

  8. Java程序性能优化之性能概述

    性能的基本概念 一).什么叫程序的性能? 程序运行所需的内存和时间. 二).性能的表现形式: 1).执行速度: 程序的反应是否迅速,响应时间是否足够短. 2).启动时间:程序从运行到可以处理正常业务所 ...

  9. Android 性能优化(3)性能工具之「调试 GPU 过度绘制」Debug GPU Overdraw Walkthrough-查看哪些view过度绘制了

    Debug GPU Overdraw Walkthrough 1.In this document Prerequisites Visualizing Overdraw You should also ...

随机推荐

  1. AjaxFileUpload文件上传组件(php+jQuery+ajax)

    jQuery插件AjaxFileUpload可以实现ajax文件上传,下载地址:http://www.phpletter.com/contents/ajaxfileupload/ajaxfileupl ...

  2. 携程Apollo(阿波罗)配置中心在Spring Boot项目快速集成

    前提:先搭建好本地的单机运行项目:http://www.cnblogs.com/EasonJim/p/7643630.html 说明:下面的示例是基于Spring Boot搭建的,对于Spring项目 ...

  3. MongoDB小结01 - MongoDB简介

    我们为什么要去学习MongoDB MongoDB是一种强大.灵活.可扩展的数据存储方式. 丰富的数据模型 MongoDB是面向文档的数据库,不是关系型数据库.它将原来'行'(row)的概念换成了更加灵 ...

  4. Java使用Memcached和Redis简单示例

    package xmq.study.memcached; import java.io.IOException; import java.net.InetSocketAddress; import n ...

  5. Android多线程研究(3)——线程同步和相互排斥及死锁

    为什么会有线程同步的概念呢?为什么要同步?什么是线程同步?先看一段代码: package com.maso.test; public class ThreadTest2 implements Runn ...

  6. centos7grub2 引导win10

    centos7+win10安装完成之后,使用gurb2引导win10系统 方式:使用ntfs-3g 步骤: 1.加源  wget -O /etc/yum.repos.d/epel.repo http: ...

  7. Creating A Simple Web Server With Golang

    原文:https://tutorialedge.net/post/golang/creating-simple-web-server-with-golang/ -------------------- ...

  8. JAVA进阶-网络编程

    >通过套接字连接server Socket指代套接字 >读取随意站点的首页 --------- /** * @author Lean @date:2014-10-9 */ public c ...

  9. HDU 1269 迷宫城堡 最大强连通图题解

    寻找一个迷宫是否是仅仅有一个最大强连通图. 使用Tarjan算法去求解,经典算法.必需要学习好,要自己创造出来是十分困难的了. 參考资料:https://www.byvoid.com/blog/scc ...

  10. Highcharts数据表示(3)

    Highcharts数据表示(3) 採用对象数组的形式,能够明白节点上每一个项目的值.可是当节点较多时,会造成大量的冗余代码. 假设不写配置项名称,对象数组就能够简化二维数组.形式例如以下: data ...