1. 程式人生 > >Android客戶端效能工具4:gfxinfo輸出總結

Android客戶端效能工具4:gfxinfo輸出總結

adb shell dumpsys gfxinfo net.oneplus.launcher framestats

Applications Graphics Acceleration Info:
Uptime: 22215460 Realtime: 38892707

** Graphics info for pid 4731 [net.oneplus.launcher] **

Stats since: 54444436332ns
Total frames rendered: 11835
Janky frames: 2803 (23.68%)
50th percentile: 12ms
90th
percentile: 21ms 95th percentile: 27ms 99th percentile: 61ms Number Missed Vsync: 296 Number High input latency: 32 Number Slow UI thread: 1092 Number Slow bitmap uploads: 159 Number Slow issue draw commands: 1251 HISTOGRAM: 5ms=1254 6ms=581 7ms=663 8ms=697 9ms=720 10ms=930 11ms=917 12ms=981 13ms=753 14ms
=646 15ms=530 16ms=597 17ms=419 18ms=332 19ms=298 20ms=320 21ms=179 22ms=140 23ms=91 24ms=73 25ms=69 26ms=33 27ms=35 28ms=29 29ms=31 30ms=30 31ms=24 32ms=53 34ms=29 36ms=42 38ms=33 40ms=35 42ms=34 44ms=22 46ms=16 48ms=27 53ms=26 57ms=21 61ms=16 65ms=19 69ms=13 73ms=11 77ms=12 81ms=12 85ms=2 89ms=2 93ms=5 97ms
=2 101ms=2 105ms=1 109ms=2 113ms=0 117ms=4 121ms=1 125ms=0 129ms=0 133ms=1 150ms=9 200ms=1 250ms=3 300ms=3 350ms=0 400ms=1 450ms=0 500ms=0 550ms=0 600ms=1 650ms=1 700ms=0 750ms=0 800ms=1 850ms=0 900ms=0 950ms=0 1000ms=0 1050ms=0 1100ms=0 1150ms=0 1200ms=0 1250ms=0 1300ms=0 1350ms=0 1400ms=0 1450ms=0 1500ms=0 1550ms=0 1600ms=0 1650ms=0 1700ms=0 1750ms=0 1800ms=0 1850ms=0 1900ms=0 1950ms=0 2000ms=0 2050ms=0 2100ms=0 2150ms=0 2200ms=0 2250ms=0 2300ms=0 2350ms=0 2400ms=0 2450ms=0 2500ms=0 2550ms=0 2600ms=0 2650ms=0 2700ms=0 2750ms=0 2800ms=0 2850ms=0 2900ms=0 2950ms=0 3000ms=0 3050ms=0 3100ms=0 3150ms=0 3200ms=0 3250ms=0 3300ms=0 3350ms=0 3400ms=0 3450ms=0 3500ms=0 3550ms=0 3600ms=0 3650ms=0 3700ms=0 3750ms=0 3800ms=0 3850ms=0 3900ms=0 3950ms=0 4000ms=0 4050ms=0 4100ms=0 4150ms=0 4200ms=0 4250ms=0 4300ms=0 4350ms=0 4400ms=0 4450ms=0 4500ms=0 4550ms=0 4600ms=0 4650ms=0 4700ms=0 4750ms=0 4800ms=0 4850ms=0 4900ms=0 4950ms=0 Caches: Current memory usage / total memory usage (bytes): TextureCache 3108068 / 100663296 LayerCache 0 / 67108864 (numLayers = 0) Layers total 0 (numLayers = 0) RenderBufferCache 0 / 12582912 GradientCache 0 / 1048576 PathCache 0 / 40894464 TessellationCache 0 / 1048576 TextDropShadowCache 108736 / 7340032 PatchCache 128 / 131072 FontRenderer A8 60887 / 4194304 A8 texture 0 60887 / 4194304 FontRenderer RGBA 0 / 0 FontRenderer total 60887 / 4194304 Other: FboCache 0 / 0 Total memory usage: 7411236 bytes, 7.07 MB Pipeline=FrameBuilder Profile data in ms: net.oneplus.launcher/net.oneplus.launcher.Launcher/android.view.ViewRootImpl@a827964 (visibility=0) Draw Prepare Process Execute 5.41 0.26 3.94 0.77 2.54 0.23 9.28 1.34 8.46 7.72 23.74 1.36 1.81 0.20 1.17 2.42 9.37 0.23 6.01 0.66 1.30 0.19 16.54 0.59 1.20 0.22 15.05 0.47 1.15 0.27 16.66 0.90 1.87 0.44 11.98 2.56 3.19 0.42 3.83 1.29 1.57 0.36 2.11 0.88 1.49 0.31 2.06 0.85 1.41 0.30 2.23 0.91 2.00 0.32 2.00 0.92 3.45 0.39 2.97 1.19 ---PROFILEDATA--- Flags,IntendedVsync,Vsync,OldestInputEvent,NewestInputEvent,HandleInputStart,AnimationStart,PerformTraversalsStart,DrawStart,SyncQueued,SyncStart,IssueDrawCommandsStart,SwapBuffers,FrameCompleted,DequeueBufferDuration,QueueBufferDuration, 0,21256019939003,21256019939003,9223372036854775807,0,21256021611264,21256021663399,21256021840691,21256023720795,21256025349180,21256025417982,21256025679753,21256029621160,21256030392410,491000,416000, 0,21256036634257,21256036634257,9223372036854775807,0,21256037009024,21256037028503,21256037252253,21256038165482,21256039177670,21256039226160,21256039455118,21256048731055,21256050073347,432000,376000 ---PROFILEDATA--- View hierarchy: net.oneplus.launcher/net.oneplus.launcher.Launcher/android.view.ViewRootImpl@a827964 368 views, 466.32 kB of display lists Total ViewRootImpl: 1 Total Views: 368 Total DisplayList: 466.32 kB

定義frameInterval為處理一幀的理想時間 1/fps
這是dumpsys一次一加桌面的gfxinfo,篇幅原因中間截去了一些資訊,我們逐行說明含義
Stats since: 54444436332ns  開始記錄的時間
Total frames rendered: 11835  總幀數
Janky frames: 2803 (23.68%)  janky的幀數以及百分比
50th percentile: 12ms      
90th percentile: 21ms      
95th percentile: 27ms
99th percentile: 61ms
Number Missed Vsync: 296   處理vsync延遲1ms以上的幀數量
Number High input latency: 32  處理input耗時超過1.5*frameInterval的幀數量
Number Slow UI thread: 1092  main thread處理ui耗時超過0.5*frameInterval的幀數量
Number Slow bitmap uploads: 159   render thread同步資料耗時超過0.2*frameInterval的幀的數量
Number Slow issue draw commands: 1251 繪製和上傳到sf耗時超過0.75*frameInterval的幀的數量

uint32_t JankTracker::findPercentile(const ProfileData* data, int percentile) {
    int pos = percentile * data->totalFrameCount / 100;
    int remaining = data->totalFrameCount - pos;
    for (int i = data->slowFrameCounts.size() - 1; i >= 0; i--) {
        remaining -= data->slowFrameCounts[i];
        if (remaining <= 0) {
            return (i * kSlowFrameBucketIntervalMs) + kSlowFrameBucketStartMs;
        }
    }
    for (int i = data->frameCounts.size() - 1; i >= 0; i--) {
        remaining -= data->frameCounts[i];
        if (remaining <= 0) {
            return frameTimeForFrameCountIndex(i);
        }
    }
    return 0;
}

上邊的{$number}th 的計算過程,不太好用語言描述,可以參考分析janktracker的文章

HISTOGRAM: 5ms=1254 6ms=581 7ms=663 8ms=697 9ms=720 10ms=930 11ms=917 12ms=981 13ms=753 14ms=646 15ms=530 16ms=597 17ms=419 18ms=332 19ms=298 20ms=320 21ms=179 22ms=140 23ms=91 24ms=73 25ms=69 26ms=33 27ms=35 28ms=29 29ms=31 30ms=30 31ms=24 32ms=53 34ms=29 36ms=42 38ms=33 40ms=35 42ms=34 44ms=22 46ms=16 48ms=27 53ms=26 57ms=21 61ms=16 65ms=19 69ms=13 73ms=11 77ms=12 81ms=12 85ms=2 89ms=2 93ms=5 97ms=2 101ms=2 105ms=1 109ms=2 113ms=0 117ms=4 121ms=1 125ms=0 129ms=0 133ms=1

這段輸出一段直方圖,輸出用時秒數的幀數,如耗時5s的幀數為1254.

後面部分輸出記憶體相關的資訊

Caches:
Current memory usage / total memory usage (bytes):
  TextureCache          3108068 / 100663296       紋理快取已使用大小/最大可用大小
  LayerCache                  0 / 67108864 (numLayers = 0)  layer快取使用大小/最大可用大小(texture)
  Layers total          0 (numLayers = 0)               layer數量
  RenderBufferCache           0 / 12582912        
  GradientCache               0 /  1048576
  PathCache                   0 / 40894464
  TessellationCache           0 /  1048576
  TextDropShadowCache    108736 /  7340032
  PatchCache                128 /   131072
  FontRenderer A8         60887 /  4194304
    A8   texture 0        60887 /  4194304
  FontRenderer RGBA           0 /        0
  FontRenderer total      60887 /  4194304
Other:
  FboCache                    0 /        0
Total memory usage:
  7411236 bytes, 7.07 MB             

上面都是快取的資訊也沒啥好說的,使用快取的總大小

後面一段列印FrameInfoVisualizer的統計資訊
Draw Prepare Process Execute
5.41 0.26 3.94 0.77
2.54 0.23 9.28 1.34
8.46 7.72 23.74 1.36
1.81 0.20 1.17 2.42
9.37 0.23 6.01 0.66
1.30 0.19 16.54 0.59
1.20 0.22 15.05 0.47
1.15 0.27 16.66 0.90
1.87 0.44 11.98 2.56
3.19 0.42 3.83 1.29
1.57 0.36 2.11 0.88
1.49 0.31 2.06 0.85
1.41 0.30 2.23 0.91
2.00 0.32 2.00 0.92
3.45 0.39 2.97 1.19
draw行代表繪製資訊
prepare 同步時間
Process gl繪製時間
Execute swapbuffer時間

—PROFILEDATA—
Flags,IntendedVsync,Vsync,OldestInputEvent,NewestInputEvent,HandleInputStart,AnimationStart,PerformTraversalsStart,DrawStart,SyncQueued,SyncStart,IssueDrawCommandsStart,SwapBuffers,FrameCompleted,DequeueBufferDuration,QueueBufferDuration,
0,21256019939003,21256019939003,9223372036854775807,0,21256021611264,21256021663399,21256021840691,21256023720795,21256025349180,21256025417982,21256025679753,21256029621160,21256030392410,491000,416000,
0,21256036634257,21256036634257,9223372036854775807,0,21256037009024,21256037028503,21256037252253,21256038165482,21256039177670,21256039226160,21256039455118,21256048731055,21256050073347,432000,376000
—PROFILEDATA—
這段列印了每一幀的統計資訊(最多120幀)

View hierarchy:

net.oneplus.launcher/net.oneplus.launcher.Launcher/[email protected]
368 views, 466.32 kB of display lists  view的數量大小,通過allocer統計 

Total ViewRootImpl: 1     viewroot總數量
Total Views: 368      view總數量
Total DisplayList: 466.32 kB  總大小

這段會列印每個viewroot的資訊