您的位置:首页 > 移动开发 > Android开发

【资源集合帖】Android 性能测试-FPS

2017-11-03 14:07 513 查看


测试背景: 

APP 在测试机运行一段时间后出现手机发烫、卡顿、高 CPU 占有率的现象。将应用切入后台进行 CPU 数据的监测,结果显示,即使应用不进行任何操作,应用的 CPU 占有率都会持续的增长

卡顿的原因大致有:布局性能不好,内存垃圾回收机制(GC)--内存抖动(大量的内存在短期内占用和释放),CPU占用过高,硬件加速,过度绘制

参考网址:

https://github.com/alexoro/android-dumpsys-gfxinfo-monitoring

http://www.apkbus.com/forum.php?mod=viewthread&tid=116357

https://github.com/sherryshare/systrace_analysis_tool

 

工具使用次序:

首先使用GPU profile或使用adb shell dumpsys gfxinfo得到的速度,如果界面卡顿这些值应该大于16.67ms,这时候就需要使用traceview或systrace抓到详细的
4000
信息给开发提供。


应用profile trace 

步骤:

如果出现<60FPS的情况,用docs/tools/debugging/debugging-tracing.html

adb shell am profile start <package> /data/local/tmp/xxx.trace     #在测试之前启用

测试。。。。

adb shell am profile stop <package>测试之后立即执行,尽量让start 和stop短,因为越长越难分析。

adb pull /data/local/tmp/xxx.trace . #导出trace后用traceview查看。


使用systrace进行 

file:///home/alex/Android/Sdk/docs/tools/debugging/systrace.html

Tracing on Android 4.3 and higher

The general syntax for running Systrace from the command line is as follows.
$ python systrace.py [options] [category1] [category2] ... [categoryN]


Here is an example execution run that sets trace tags and generates a trace from a connected device.
$ cd ''android-sdk''/platform-tools/systrace
$ python systrace.py --time=10 -o mynewtrace.html sched gfx view wm


To set trace tags for Systrace using the device user interface:

    On the device connected for tracing, navigate to: Settings > Developer options > Monitoring > Enable traces.

    Select the categories of processes to be traced and click OK.

options:

      gfx - Graphics

       input - Input

        view - View System

     webview - WebView

          wm - Window Manager

          am - Activity Manager

          sm - Sync Manager

       audio - Audio

       video - Video

      camera - Camera

         hal - Hardware Modules

         app - Application

         res - Resource Loading

      dalvik - Dalvik VM

          rs - RenderScript

      bionic - Bionic C Library

       power - Power Management

       sched - CPU Scheduling

        freq - CPU Frequency

        idle - CPU Idle

        load - CPU Load

reference:

http://www.tinylab.org/android-app-launch-speed-optimization-series-part1-systrace-usage/#systrace--3


应用帧率FPS测量 

Android应用帧率FPS是衡量应用流畅度的一个非常重要的指标,可以根据FPS对应用做一些优化,那么在开发过程中如何来测试我们的应用的FPS呢?

准备工具:Eclipse + Android测试终端

 

测试步骤:

1、在设置里打开GPU呈现模式分析。点击Android设备的“设置”->"开发者选项",然后勾选“GPU呈现模式分析”(各终端可能不一样,重点是就算adb shell dumpsys gfxinfo)。

2、重启我们的应用。启动应用以后,在应用的页面上做滑动。

3、打开命令行,在命令行输入:adb shell dumpsys gfxinfo "你自己的应用名字" > f:\fps.txt




 

结果分析:

1、打开生成的fps.txt,找到Profile data in ms这部分数据。 

2、为了看得更直接,我们可以把数据放到Excel中,然后以图表的形式进行查看。

3、从图中可以看出来,我这个应用的流畅度是很低的,正常情况下帧率应该在16ms左右,如果1秒60帧的话,而且Execute时间太长!所以是需要进行优化的


测试背景: 

APP 在测试机运行一段时间后出现手机发烫、卡顿、高 CPU 占有率的现象。将应用切入后台进行 CPU 数据的监测,结果显示,即使应用不进行任何操作,应用的 CPU 占有率都会持续的增长

参考网址:

https://github.com/alexoro/android-dumpsys-gfxinfo-monitoring

http://www.apkbus.com/forum.php?mod=viewthread&tid=116357

https://github.com/sherryshare/systrace_analysis_tool

 


应用profile trace 

步骤:

如果出现<60FPS的情况,用docs/tools/debugging/debugging-tracing.html

adb shell am profile start <package> /data/local/tmp/xxx.trace     #在测试之前启用

测试。。。。

adb shell am profile stop <package>测试之后立即执行,尽量让start 和stop短,因为越长越难分析。

adb pull /data/local/tmp/xxx.trace . #导出trace后用traceview查看。


使用systrace进行 

file:///home/alex/Android/Sdk/docs/tools/debugging/systrace.html

Tracing on Android 4.3 and higher

The general syntax for running Systrace from the command line is as follows.
$ python systrace.py [options] [category1] [category2] ... [categoryN]


Here is an example execution run that sets trace tags and generates a trace from a connected device.
$ cd ''android-sdk''/platform-tools/systrace
$ python systrace.py --time=10 -o mynewtrace.html sched gfx view wm


To set trace tags for Systrace using the device user interface:

    On the device connected for tracing, navigate to: Settings > Developer options > Monitoring > Enable traces.

    Select the categories of processes to be traced and click OK.

options:

      gfx - Graphics

       input - Input

        view - View System

     webview - WebView

          wm - Window Manager

          am - Activity Manager

          sm - Sync Manager

       audio - Audio

       video - Video

      camera - Camera

         hal - Hardware Modules

         app - Application

         res - Resource Loading

      dalvik - Dalvik VM

          rs - RenderScript

      bionic - Bionic C Library

       power - Power Management

       sched - CPU Scheduling

        freq - CPU Frequency

        idle - CPU Idle

        load - CPU Load

reference:

http://www.tinylab.org/android-app-launch-speed-optimization-series-part1-systrace-usage/#systrace--3


应用帧率FPS测量 

Android应用帧率FPS是衡量应用流畅度的一个非常重要的指标,可以根据FPS对应用做一些优化,那么在开发过程中如何来测试我们的应用的FPS呢?

准备工具:Eclipse + Android测试终端

 

测试步骤:<
adb9
/div>

1、在设置里打开GPU呈现模式分析。点击Android设备的“设置”->"开发者选项",然后勾选“GPU呈现模式分析”(各终端可能不一样,重点是就算adb shell dumpsys gfxinfo)。

2、重启我们的应用。启动应用以后,在应用的页面上做滑动。

3、打开命令行,在命令行输入:adb shell dumpsys gfxinfo "你自己的应用名字" > f:\fps.txt

 解析:

adb shell dumpsys gfxinfo packageName | awk '/Execute/,/hierarchy/{if(i>1)print x;x=$0;i++}' | sed /^[[:space:]]*$/d|awk '{if(length($0)==16print $1,$2,$3}'

结果分析:

1、打开生成的fps.txt,找到Profile data in ms这部分数据。

 

2、为了看得更直接,我们可以把数据放到Excel中,然后以图表的形式进行查看。

3、从图中可以看出来,我这个应用的流畅度是很低的,正常情况下帧率应该在16ms左右,如果1秒60帧的话,而且Execute时间太长!所以是需要进行优化的

60fps<==>per frame 《16ms
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: