A man you hanging open Android performance test methods, impatient up!

Android performance testing, like pc performance test is divided into client and server, but performance testing on the client's divided into two categories, for application performance testing, including a lot of test items, such as start time, memory, CPU, GPU, power consumption, traffic and so on. But for rom version of the performance test, the general concern power consumption.

Different versions of the performance test  

1, rom version of the performance test

rom version will focus on the general power test, but with the application of power test version of rom-power testing will vary, of course, but with differences in the design of cases, tools are still using Agilent instrument for power.

2, application performance testing

Application performance testing, for the start-up time, memory, CPU test we generally use third-party tools provided to assist external testing, such as GT, safety testing, these tools are based on the principle of some api calls to get to the bottom of the Android the values ​​used in the test, of course, we can also use other methods, such as using a adb Android itself provides to complete the test.

A man you hanging open Android performance test methods, impatient up!

For GPU, power consumption, and other tests, obtained by third-party tools to test values ​​are generally not very accurate, this time we need to introduce hardware to be tested, GPU can be tested using high-speed cameras, power consumption can be used multimeter or Agilent power meter for testing (ps: there is hardware ability can DIY a small plate).

3, Android performance test

The main sub-content is content today detailed, specific analysis, see below.

Performance test on Android  

1, the start time

First of all, we say it is time to start. About test application start-up time, divided into three categories:

① first start - the time it takes to start the application for the first time

② not the first time launch - the non-application of the time it takes for the first time start

③ switch application interface - switching time within the application interface so it takes time to start testing how to do it, we are generally divided into two categories, one for the use of software to test, one for the use of hardware to test, first of all we say He said software testing methods, most people probably are more familiar with the use of DisplayManager Android provides to get the activity start time.

A man you hanging open Android performance test methods, impatient up!

step:

A man you hanging open Android performance test methods, impatient up!

通过计算activity最后剩余的时间之和即可(这里可以使用excel表格自动相加也可以使用算法,我就不详细介绍了)。

除了Display Manager的打印时间方法后,还有通过关注am的启动时间及Display Manager打印的结束时间,通过两者时间之间想减也能得到应用的启动时间,还有可以通过Power Manager来计算打印时间,在应用启动的时候,我们可以关注Activity Manager-Launch的变化来计算应用的启动时间,还有可以通过截图统计启动时间,对于自研应用,最效率的莫过于直接在程序中插入打印时间的节点了。

除了软件测试的方法,还有硬件测试,我们可以使用高速相机或者手机,采用录像的方法把应用启动过程给录制下来,然后通过人工数帧或者程序数帧的方式计算启动时间。

2、内存消耗

1)内存消耗概念

这个测试节点的设计目标是为了让应用不占用过多的系统资源,且及时释放内存,保障整个系统的稳定性,当然关于内存测试,在这里我们需要引入几个概念:空闲状态、中等规格、满规格。

A man you hanging open Android performance test methods, impatient up!

空闲状态:指打开应用后,点击home键让应用后台运行,此时应用处于的状态叫做空闲。

中等规格和满规格:指的是对应用的操作时间的间隔长短不一,中等规格时间较长,满规格时间较短。

接下来我们说说在内存测试中,存在很多测试子项,如下清单所示:

①空闲状态下的应用内存消耗情况
②中等规格状态下的应用内存消耗情况
③满规格状态下的应用内存消耗情况
④应用内存峰值情况
⑤应用内存泄露情况
⑥应用是否常驻内存
⑦压力测试后的内存使用情况

2)关于Android内存测试方法分类

①使用Android本身提供的ActivityManager.MemoryInfo()方法获得(此方法请百度或google)此类第三方工具有如网易的Emmagee、安测试、腾讯的GT等。

②使用Android提供的对应内容,来获取。

A man you hanging open Android performance test methods, impatient up!

③使用Android提供的procrank。这里我们详解一下procrank方法(批处理)。

首先,去google获取procrank、procmem、libpagemap.so三个文件;然后push文件,执行;最后,剩下的就是整理测试数据了。

A man you hanging open Android performance test methods, impatient up!

3)关于内存泄露方面的测试

可以通过几个方面来测试:

①通过monkey压力测试记录内存使用情况,分析数据曲线图及日志情况;
②通过eclipse上的mat+heap来分析存在内存泄露方面的节点。

CPU方面的测试  

1)子项清单

CPU跟内存一样,存在一些测试子项,如下清单所示:

①空闲状态下的应用CPU消耗情况
②中等规格状态下的应用CPU消耗情况
③满规格状态下的应用CPU消耗情况
④应用CPU峰值情况

2)CPU的测试方法

1.使用Android提供的

A man you hanging open Android performance test methods, impatient up!

2.使用top命令

A man you hanging open Android performance test methods, impatient up!

3.第三方软件

例如:3Dmax、安兔兔等。

3)GPU的测试方法

自从CPU及内存后,GPU这个词对于PC性能测试者也不陌生了。3Dmax、安兔兔等之类的第三方软件,让GPU在移动端性能测试领域都知晓。但对于应用的GPU该如何来测试呢?我们先引入几个名词:过度绘制、帧率、帧方差。

A man you hanging open Android performance test methods, impatient up!

过度绘制:是指界面显示的activity套接了多层而导致;

帧率:是指屏幕刷新率;

帧方差:是指屏幕刷新帧间隔方差。

对于GPU的测试主要包括以下几个测试子项:界面过度绘制、屏幕滑动帧速率、屏幕滑动平滑度。

①过度测绘

它主要通过人工进行测试。打开开发者选项中的显示GPU过度绘制来进行测试(PS:只有Android4.2及以上的版本才具备此功能)。验收的标准为:

a、不允许出现黑色像素
b、不允许存在4x过度绘制
c、不允许存在面积超过屏幕1/4区域的3x过度绘制(淡红色区域)

②屏幕滑动帧速率的2种主要方法

→ 软件测试方法

a、手机端需打开开发者选项中的启用跟踪后勾选Graphics和View

b、启动SDK工具Systrace插件,勾选被测应用,点击Systrace插件,在弹出的对话框中设置持续抓取时间,在tracetaps下面勾选gfx及view选项,

c、人滑动界面可以通过节拍来进行滑动或者扫动,帧率数据会保存到默认路径下,默认名称为trace.html

d、将trace.html文件拷贝到linux系统下通过命令进行转换,生成trace.csv文件:

A man you hanging open Android performance test methods, impatient up!

e、用excel打开文件计算得到帧率

→ 硬件方法

这里需要引入高速相机,打开高速相机,开启摄像模式,录制人滑动或者扫动被测应用的视频,再通过人工或者程序数帧的方法对结果进行计算得到帧率。

A man you hanging open Android performance test methods, impatient up!

③屏幕滑动平滑度测试

方法如同帧率测试,唯一的差异就是最后的结果计算公式的差异。GPU的测试目前业界使用的均为硬件来进行,软件测试的数据相较硬件差异较大,对于帧率及帧方差的测试标准而言,需对待不同机型设定不同的标准。

功耗测试    

1)功耗测试类别

功耗测试主要从以下几个方面入手进行测试:

a、测试手机安装目标APK前后待机功耗无明显差异。
b、常见使用场景中能够正常进入待机,待机电流在正常范围内。
c、长时间连续使用应用无异常耗电现象。

A man you hanging open Android performance test methods, impatient up!

2)测试方法

①软件测试

A、第三方工具:如金山电池管家之类的;

B、自写工具:这里一般会使用3种方法:

第一种,基于Android提供的PowerManager.WakeLock来进行;

第二种,比较复杂一点,功耗的计算=CPU消耗+Wakelock消耗+数据传输消耗+GPS消耗+Wi-Fi连接消耗;

第三种,通过adbshelldumpsysbattery来获取。

②硬件测试

在这里,我们一般使用万用表或者功耗仪进行测试。使用功耗仪测试的时候,需要制作假电池来进行的,有些不能拔插电池的手机,还需要焊接才能进行功耗测试。

③流量测试

性能测试的——流量,当然我所指的性能测试是针对大部分应用而言的,可能还有部分应用会关注网速、弱网之类的测试。

A man you hanging open Android performance test methods, impatient up!

1)流量测试,同样需要引入几个名词:中等负荷、高负荷。

中等负荷:应用正常操作
高负荷:应用极限操作

2)测试项包括:

a、应用首次启动流量提示;
b、应用后台连续运行2小时的流量值;
c、应用高负荷运行的流量峰值;
d、应用中等负荷运行时的流量均值;

3)流量测试一般都是用软件来进行的,这里我们一般分为2类:

a、采用市场提供的第三方工具来进行测试,如流量宝之类的;
b、自研工具进行测试。

最后

其实对于程序员来说,要学习的知识内容、技术有太多太多,要想不被环境淘汰就只有不断提升自己,从来都是我们去适应环境,而不是环境来适应我们!

这里附上上述的技术体系图相关的几十套腾讯、头条、阿里、美团等公司19年的面试题,把技术点整理成了视频和PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节,由于篇幅有限,这里以图片的形式给大家展示一部分。

相信它会给大家带来很多收获:

A man you hanging open Android performance test methods, impatient up!

A man you hanging open Android performance test methods, impatient up!

上述【高清技术脑图】以及【配套的架构技术PDF】可以 加我wx:X1524478394 免费获取!

When programmers easily, when a good programmer is a need to learn from junior programmer to senior programmer, architect from primary to senior architect, or to management, technical director from technical manager to each stage We need to have different capabilities. Early to determine their career direction, in order to throw off their peers at work and in capacity building.

Guess you like

Origin blog.51cto.com/14332859/2465280