Android 性能优化(21)*性能工具之「GPU呈现模式分析」Profiling GPU Rendering Walkthrough:分析View显示是否超标
Profiling GPU Rendering Walkthrough
1.In this document
You should also read
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
- A mobile device running at least Android 4.1 with Developer Options enabled.
3.Working with Profile GPU Rendering 开启Profile GPU Rendering 的方法
- On your mobile device, go to Settings >Developer Options.
- In the Monitoring section, select Profile GPU Rendering.
- In the Profile GPU Rendering popup, choose On screen as bars to overlay the graphs on the screen of your mobile device.
- 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”的区域
每列数据显示了渲染每一帧需要的时间:
- Draw 是在Java中创建显示列表所需要的时间。这个值显示了运行绘图函数用了多长时间,比如View.onDraw(Canvas)。
- Process 是Android 2D引擎渲染显示列表所需要的时间。在界面中View数目越多,则有越多的绘制命令需要执行。
- Execute 是把一帧数据送到屏幕上排版显示的时间,这个时间通常比较小。
屏幕上显示的每一帧都要经过3步:java创建绘制列表,渲染引擎显示列表,把每一帧送到屏幕上排版显示。
6.3 初步分析
要流畅的运行60帧/秒, 则需要每帧的处理时间不超过16ms。如上图中有个36.21 ,如果多个超过16ms,那么说明有严重问题。
Android 性能优化(21)*性能工具之「GPU呈现模式分析」Profiling GPU Rendering Walkthrough:分析View显示是否超标的更多相关文章
- Android开发者选项——Gpu呈现模式分析
对于Android用户来说,无论你用的什么品牌的手机,在开发者选项中都能发现“玄学曲线”的开关,之所以称其为玄学曲线,还是因为它被很多网友用于测试一个说不清道不明的东西——流畅度.到底多流畅才叫流畅, ...
- 浅谈AndroidGPU过度绘制、GPU呈现模式分析及相关优化
在真机设备下有一个开发者选项,这个大家都知道,我们最常用的就打开'USB调试'功能,方便真机调试. 在这开发者选项中还有个选项,'调试GPU过度绘制' 这里选择第二个选项'显示过度绘制区域' 可以看到 ...
- Android开发学习之路--性能优化之常用工具
android性能优化相关的开发工具有很多很多种,这里对如下六个工具做个简单的使用介绍,主要有Android开发者选项,分析具体耗时的Trace view,布局复杂度工具Hierarchy Vie ...
- Android 性能优化 五 性能分析工具dumpsys的使用
Android提供的dumpsys工具能够用于查看感兴趣的系统服务信息与状态,手机连接电脑后能够直接命令行运行adb shell dumpsys 查看全部支持的Service可是这样输出的太多,能够通 ...
- MYSQL之性能优化 ----MySQL性能优化必备25条
今天,数据库的操作越来越成为整个应用的性能瓶颈了,这点对于Web应用尤其明显.关于数据库的性能,这并不只是DBA才需要担心的事,而这更是我 们程序员需要去关注的事情.当我们去设计数据库表结构,对操作数 ...
- 性能优化 | JVM性能调优篇——来自阿里P7的经验总结
VM 调优概述: 性能定义: 吞吐量 - 指不考虑 GC 引起的停顿时间或内存消耗,垃圾收集器能支撑应用达到的最高性能指标. 延迟 - 其度量标准是缩短由于垃圾啊收集引起的停顿时间或者完全消除因垃圾收 ...
- 前端性能优化jQuery性能优化
一.使用合适的选择器 $("#id"); 1.使用id来定位DOM元素无疑是最佳提高性能的方式,因为jQuery底层将直接调用本地方法document.getElementById ...
- Java程序性能优化之性能概述
性能的基本概念 一).什么叫程序的性能? 程序运行所需的内存和时间. 二).性能的表现形式: 1).执行速度: 程序的反应是否迅速,响应时间是否足够短. 2).启动时间:程序从运行到可以处理正常业务所 ...
- Android 性能优化(3)性能工具之「调试 GPU 过度绘制」Debug GPU Overdraw Walkthrough-查看哪些view过度绘制了
Debug GPU Overdraw Walkthrough 1.In this document Prerequisites Visualizing Overdraw You should also ...
随机推荐
- openjudge7624 山区建小学
描述 政府在某山区修建了一条道路,恰好穿越总共m个村庄的每个村庄一次,没有回路或交叉,任意两个村庄只能通过这条路来往.已知任意两个相邻的村庄之间的距离为di(为正整数),其中,0 < i < ...
- msp430入门编程11
msp430中C语言的模块化头文件及实现11 msp430中C语言的模块化头文件及库文件12 msp430入门学习 msp430入门编程
- 无权二分图最大匹配 HDU2063 匈牙利算法 || Hopcroft-Karp
参考两篇比较好的博客 http://www.renfei.org/blog/bipartite-matching.html http://blog.csdn.net/thundermrbird/art ...
- POJ 2785_4 Values whose Sum is 0
题意: A,B,C,D四组数中各取一个数,使这四个数相加为0,问有多少组取法? 分析: 四个数列有n4种取法,规模较大,但是可以将他们分成AB,CD两组,分别枚举,最后再合并. 代码: #includ ...
- 创建Django项目(二)——数据库配置
2013-08-05 20:53:44| 1.数据库配置 举例是用MySQL数据库,首先在settings文件中做配置,如下: DATABASES = { ' ...
- Nginx+Tomcat+Memcached负载均衡和session共享
1. 演示搭建 说明:本文参考网络日志http://blog.csdn.net/remote_roamer/article/details/51133790,结合实际操作,仅做个演示记录. 1.1. ...
- Bug记载2之Vue.JS路由定义的位置
<!DOCTYPE html><html lang="en"> <head> <meta charset="UTF-8" ...
- 几种常见排序算法的java实现
一.几种常见的排序算法性能比較 排序算法 最好时间 平均时间 最坏时间 辅助内存 稳定性 备注 简单选择排序 O(n^2) O(n^2) O(n^2) O(1) 不稳定 n小时较好 直接插入排序 O( ...
- webpack-入口篇
入口起点[Entry Points]: 单个入口(简写)语法 用法:entry: string|Array<string> 例子(webpack.config.js) const conf ...
- 合并小图片利器TexturePacker GUI
合并小图片,能够非常大的节省网络开销.尤其如今的站点非常喜欢使用大量的小图标来做一些友好提示.当然使用图片文字也是一种选择. 只是这里推荐的是TexturePacker GUI ,这个确实是一款利器. ...