最近在学习 Android 稳定性测试相关的知识点,目前主要参考xinxi 的 持续集成中的 Android 稳定性测试, 但是在看到FPS相关指标的数据的时候,我发现了一些不一样的地方,然后发现社区多数的计算方法都是来自这一篇文章 FPS 计算方法的比较, 然后我就产生了疑问?我的数据是这样的:

环境

Applications Graphics Acceleration Info:
Uptime: 17498916 Realtime: 17498916

** Graphics info for pid 1306 [com.xueqiu.android] **

Stats since: 1014402977980ns
Total frames rendered: 15148
Janky frames: 4108 (27.12%)
90th percentile: 18ms
95th percentile: 22ms
99th percentile: 44ms
Number Missed Vsync: 215
Number High input latency: 9
Number Slow UI thread: 634
Number Slow bitmap uploads: 27
Number Slow issue draw commands: 3106

Caches:
Current memory usage / total memory usage (bytes):
  TextureCache         23542452 / 25165824
  LayerCache              32768 / 16777216 (numLayers = 1)
    Layer size 128x64; isTextureLayer()=0; texid=943 fbo=0; refs=1
  Layers total      32768 (numLayers = 1)
  RenderBufferCache           0 /  2097152
  GradientCache           16384 /   524288
  PathCache              198843 /  4194304
  TessellationCache      266880 /  1048576
  TextDropShadowCache         0 /  2097152
  PatchCache               4032 /   131072
  FontRenderer 0 A8     1048576 /  1048576

  FontRenderer 0 RGBA         0 /        0
  FontRenderer 0 total  1048576 /  1048576
Other:

  FboCache                    0 /        0
Total memory usage:
  25109935 bytes, 23.95 MB
Profile data in ms:
    com.xueqiu.android/com.xueqiu.android.common.MainActivity/android.view.ViewRootImpl@9e9e9b8 (visibility=0)
    Draw    Prepare Process Execute
    11.53   0.46    4.68    2.23
    3.96    0.26    4.53    9.07
    4.08    0.63    4.67    8.99
    3.45    0.48    2.48    11.92
    3.62    0.52    3.48    9.18
    5.41    0.83    4.04    3.37
    2.43    0.22    2.88    2.62
    2.14    0.26    2.80    2.04
    2.15    0.36    4.85    2.27
    3.25    0.32    3.29    2.02
    3.05    0.33    3.95    2.07
    2.24    0.22    8.27    3.37
    2.62    0.27    7.20    3.09
    1.52    0.19    3.27    1.34
    2.65    0.17    6.58    1.32
    2.60    0.12    2.71    4.74
    1.43    0.17    3.08    1.15
    2.32    0.26    2.66    1.76
    5.19    0.16    2.59    1.61


Stats since: 1014402977980ns
Total frames rendered: 15148
Janky frames: 4108 (27.12%)
90th percentile: 18ms
95th percentile: 22ms
99th percentile: 44ms
Number Missed Vsync: 215
Number High input latency: 9
Number Slow UI thread: 634
Number Slow bitmap uploads: 27
Number Slow issue draw commands: 3106
View hierarchy:

  com.xueqiu.android/com.xueqiu.android.common.MainActivity/android.view.ViewRootImpl@9e9e9b8

  629 views, 586.51 kB of display lists


Total ViewRootImpl: 1

Total Views:        629

Total DisplayList:  586.51 kB

测试代码如下:

cmd = "adb  shell dumpsys gfxinfo %s" % ('com.xueqiu.android')
result = os.popen(cmd).read().strip()
frames = [x for x in result.split('\n') if validator(x)]
for frame in frames:
    time_block = re.split(r'\s+', frame.strip())

    if len(time_block) == 3:
        print (time_block)

结果

['Applications', 'Graphics', 'Acceleration', 'Info:']
['Uptime:', '17838571', 'Realtime:', '17838571']
['Total', 'frames', 'rendered:', '15951']       
['Janky', 'frames:', '4375', '(27.43%)']        
['Number', 'Missed', 'Vsync:', '216']
['TextureCache', '23546664', '/', '25165824']   
['RenderBufferCache', '0', '/', '2097152']      
['GradientCache', '16384', '/', '524288']       
['PathCache', '198843', '/', '4194304']
['TessellationCache', '266880', '/', '1048576']
['TextDropShadowCache', '0', '/', '2097152']
['PatchCache', '4032', '/', '131072']
['FboCache', '0', '/', '0']
['25114147', 'bytes,', '23.95', 'MB']
['Profile', 'data', 'in', 'ms:']
['Draw', 'Prepare', 'Process', 'Execute']
['13.13', '0.54', '5.32', '2.91']
['4.10', '0.26', '4.73', '7.49']
['4.51', '1.13', '5.86', '6.09']
['3.01', '0.51', '3.24', '10.94']
['2.37', '1.42', '4.53', '8.74']
['1.78', '0.54', '4.79', '10.27']
['1.93', '0.78', '2.76', '12.70']
['2.52', '0.28', '2.43', '12.89']
['2.03', '0.57', '2.37', '13.17']
['2.10', '0.26', '2.37', '12.42']
['1.83', '0.47', '2.76', '12.40']
['1.42', '0.46', '2.90', '12.35']
['1.19', '0.25', '2.83', '12.86']
['1.32', '0.40', '1.92', '13.32']
['4.32', '0.68', '2.16', '10.04']
['16.73', '0.63', '4.38', '4.26']
['4.80', '0.38', '4.32', '4.00']
['3.37', '0.45', '4.69', '8.29']
['2.60', '0.53', '8.96', '5.25']
['2.90', '1.98', '7.99', '5.82']
['2.84', '0.46', '5.11', '8.96']
['1.54', '0.62', '3.27', '12.16']
['1.91', '0.29', '3.20', '12.85']
['2.60', '0.36', '4.50', '9.75']
['1.69', '1.24', '3.32', '11.90']
['2.17', '0.50', '2.28', '13.18']
['2.34', '0.37', '3.42', '11.96']

问题

修复

通过正则获取目标数据

cmd = "adb  shell dumpsys gfxinfo %s" % ('com.xueqiu.android')
result = os.popen(cmd).read().strip()
data = re.findall(r'(?<=Execute)([\w\W]+)(?=Stats)', result)
frames = [x for x in data[0].split('\n') if validator(x)]
for frame in frames:
    time_block = re.split(r'\s+', frame.strip())

    if len(time_block) == 4:
        print (time_block)

待解决问题

这个是我觉得挺好的,分享一下


↙↙↙阅读原文可查看相关链接,并与作者交流