• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.android.loganalysis.parser;
17 
18 import com.android.loganalysis.item.GfxInfoItem;
19 
20 import junit.framework.TestCase;
21 
22 import java.util.Arrays;
23 import java.util.List;
24 
25 public class GfxInfoParserTest extends TestCase {
26 
27     /**
28      * Tests gfxinfo output from M with single process.
29      */
testSingleProcess()30     public void testSingleProcess() {
31         List<String> input = Arrays.asList(
32             "** Graphics info for pid 853 [com.google.android.leanbacklauncher] **",
33             "",
34             "Stats since: 13370233957ns",
35             "Total frames rendered: 20391",
36             "Janky frames: 785 (3.85%)",
37             "90th percentile: 9ms",
38             "95th percentile: 14ms",
39             "99th percentile: 32ms",
40             "Number Missed Vsync: 155",
41             "Number High input latency: 0",
42             "Number Slow UI thread: 469",
43             "Number Slow bitmap uploads: 65",
44             "Number Slow issue draw commands: 153",
45             "",
46             "Caches:",
47             "Current memory usage / total memory usage (bytes):",
48             "  TextureCache         16055224 / 50331648",
49             "  LayerCache                  0 / 33554432 (numLayers = 0)",
50             "  Layers total          0 (numLayers = 0)",
51             "  RenderBufferCache           0 /  2097152",
52             "  GradientCache               0 /   838860",
53             "  PathCache                   0 / 25165824",
54             "  TessellationCache     1048296 /  1048576",
55             "  TextDropShadowCache         0 /  4194304",
56             "  PatchCache                  0 /   131072",
57             "  FontRenderer 0 A8      524288 /   524288",
58             "  FontRenderer 0 RGBA         0 /        0",
59             "  FontRenderer 0 total   524288 /   524288",
60             "Other:",
61             "  FboCache                    0 /        0",
62             "Total memory usage:",
63             "  17627808 bytes, 16.81 MB",
64             "",
65             "Profile data in ms:",
66             "",
67             "\tcom.google.android.leanbacklauncher/com.google.android.leanbacklauncher.MainActivity/android.view.ViewRootImpl@8dc465 (visibility=8)",
68             "Stats since: 13370233957ns",
69             "Total frames rendered: 20391",
70             "Janky frames: 785 (3.85%)",
71             "90th percentile: 9ms",
72             "95th percentile: 14ms",
73             "99th percentile: 32ms",
74             "Number Missed Vsync: 155",
75             "Number High input latency: 0",
76             "Number Slow UI thread: 469",
77             "Number Slow bitmap uploads: 65",
78             "Number Slow issue draw commands: 153",
79             "",
80             "View hierarchy:",
81             "",
82             "  com.google.android.leanbacklauncher/com.google.android.leanbacklauncher.MainActivity/android.view.ViewRootImpl@8dc465",
83             "  220 views, 177.61 kB of display lists",
84             "",
85             "",
86             "Total ViewRootImpl: 1",
87             "Total Views:        220",
88             "Total DisplayList:  177.61 kB");
89 
90         GfxInfoItem item = new GfxInfoParser().parse(input);
91 
92         assertEquals(1, item.getPids().size());
93         assertEquals("com.google.android.leanbacklauncher", item.getName(853));
94         assertEquals(20391, item.getTotalFrames(853));
95         assertEquals(785, item.getJankyFrames(853));
96         assertEquals(9, item.getPrecentile90(853));
97         assertEquals(14, item.getPrecentile95(853));
98         assertEquals(32, item.getPrecentile99(853));
99     }
100 
101     /**
102      * Test gfxinfo output from M with multiple processes.
103      */
testMultipleProcesses()104     public void testMultipleProcesses() {
105         List<String> input = Arrays.asList(
106                 "Applications Graphics Acceleration Info:",
107                 "Uptime: 6127679 Realtime: 6127679",
108                 "",
109                 "** Graphics info for pid 844 [com.google.android.leanbacklauncher] **",
110                 "",
111                 "Stats since: 12167093145ns",
112                 "Total frames rendered: 1690",
113                 "Janky frames: 125 (7.40%)",
114                 "90th percentile: 13ms",
115                 "95th percentile: 19ms",
116                 "99th percentile: 48ms",
117                 "Number Missed Vsync: 17",
118                 "Number High input latency: 0",
119                 "Number Slow UI thread: 32",
120                 "Number Slow bitmap uploads: 20",
121                 "Number Slow issue draw commands: 67",
122                 "",
123                 "Caches:",
124                 "Current memory usage / total memory usage (bytes):",
125                 "  TextureCache         16550096 / 50331648",
126                 "  LayerCache                  0 / 33554432 (numLayers = 0)",
127                 "  Layers total          0 (numLayers = 0)",
128                 "  RenderBufferCache           0 /  2097152",
129                 "  GradientCache               0 /   838860",
130                 "  PathCache                   0 / 25165824",
131                 "  TessellationCache      350424 /  1048576",
132                 "  TextDropShadowCache         0 /  4194304",
133                 "  PatchCache                  0 /   131072",
134                 "  FontRenderer 0 A8      524288 /   524288",
135                 "  FontRenderer 0 RGBA         0 /        0",
136                 "  FontRenderer 0 total   524288 /   524288",
137                 "Other:",
138                 "  FboCache                    0 /        0",
139                 "Total memory usage:",
140                 "  17424808 bytes, 16.62 MB",
141                 "",
142                 "Profile data in ms:",
143                 "",
144                 "\tcom.google.android.leanbacklauncher/com.google.android.leanbacklauncher.MainActivity/android.view.ViewRootImpl@178d02b (visibility=0)",
145                 "Stats since: 12167093145ns",
146                 "Total frames rendered: 1690",
147                 "Janky frames: 125 (7.40%)",
148                 "90th percentile: 13ms",
149                 "95th percentile: 19ms",
150                 "99th percentile: 48ms",
151                 "Number Missed Vsync: 17",
152                 "Number High input latency: 0",
153                 "Number Slow UI thread: 32",
154                 "Number Slow bitmap uploads: 20",
155                 "Number Slow issue draw commands: 67",
156                 "",
157                 "View hierarchy:",
158                 "",
159                 "  com.google.android.leanbacklauncher/com.google.android.leanbacklauncher.MainActivity/android.view.ViewRootImpl@178d02b",
160                 "  221 views, 207.24 kB of display lists",
161                 "",
162                 "",
163                 "Total ViewRootImpl: 1",
164                 "Total Views:        221",
165                 "Total DisplayList:  207.24 kB",
166                 "",
167                 "",
168                 "** Graphics info for pid 1881 [com.android.vending] **",
169                 "",
170                 "Stats since: 6092969986095ns",
171                 "Total frames rendered: 693",
172                 "Janky frames: 62 (8.95%)",
173                 "90th percentile: 16ms",
174                 "95th percentile: 26ms",
175                 "99th percentile: 81ms",
176                 "Number Missed Vsync: 17",
177                 "Number High input latency: 0",
178                 "Number Slow UI thread: 30",
179                 "Number Slow bitmap uploads: 4",
180                 "Number Slow issue draw commands: 13",
181                 "",
182                 "Caches:",
183                 "Current memory usage / total memory usage (bytes):",
184                 "  TextureCache          7369504 / 50331648",
185                 "  LayerCache                  0 / 33554432 (numLayers = 0)",
186                 "  Layers total          0 (numLayers = 0)",
187                 "  RenderBufferCache           0 /  2097152",
188                 "  GradientCache               0 /   838860",
189                 "  PathCache                   0 / 25165824",
190                 "  TessellationCache           0 /  1048576",
191                 "  TextDropShadowCache         0 /  4194304",
192                 "  PatchCache                  0 /   131072",
193                 "  FontRenderer 0 A8      524288 /   524288",
194                 "  FontRenderer 0 RGBA         0 /        0",
195                 "  FontRenderer 0 total   524288 /   524288",
196                 "Other:",
197                 "  FboCache                    0 /        0",
198                 "Total memory usage:",
199                 "  7893792 bytes, 7.53 MB",
200                 "",
201                 "Profile data in ms:",
202                 "",
203                 "\tcom.android.vending/com.google.android.finsky.activities.MainActivity/android.view.ViewRootImpl@5bd0cb2 (visibility=8)",
204                 "Stats since: 6092969986095ns",
205                 "Total frames rendered: 693",
206                 "Janky frames: 62 (8.95%)",
207                 "90th percentile: 16ms",
208                 "95th percentile: 26ms",
209                 "99th percentile: 81ms",
210                 "Number Missed Vsync: 17",
211                 "Number High input latency: 0",
212                 "Number Slow UI thread: 30",
213                 "Number Slow bitmap uploads: 4",
214                 "Number Slow issue draw commands: 13",
215                 "",
216                 "View hierarchy:",
217                 "",
218                 "  com.android.vending/com.google.android.finsky.activities.MainActivity/android.view.ViewRootImpl@5bd0cb2",
219                 "  195 views, 157.71 kB of display lists",
220                 "",
221                 "",
222                 "Total ViewRootImpl: 1",
223                 "Total Views:        195",
224                 "Total DisplayList:  157.71 kB",
225                 "",
226                 "",
227                 "** Graphics info for pid 2931 [com.google.android.videos] **",
228                 "",
229                 "Stats since: 6039768250261ns",
230                 "Total frames rendered: 107",
231                 "Janky frames: 42 (39.25%)",
232                 "90th percentile: 48ms",
233                 "95th percentile: 65ms",
234                 "99th percentile: 113ms",
235                 "Number Missed Vsync: 9",
236                 "Number High input latency: 0",
237                 "Number Slow UI thread: 28",
238                 "Number Slow bitmap uploads: 8",
239                 "Number Slow issue draw commands: 20",
240                 "",
241                 "Caches:",
242                 "Current memory usage / total memory usage (bytes):",
243                 "  TextureCache          7880000 / 50331648",
244                 "  LayerCache                  0 / 33554432 (numLayers = 0)",
245                 "  Layers total          0 (numLayers = 0)",
246                 "  RenderBufferCache           0 /  2097152",
247                 "  GradientCache               0 /   838860",
248                 "  PathCache                   0 / 25165824",
249                 "  TessellationCache           0 /  1048576",
250                 "  TextDropShadowCache         0 /  4194304",
251                 "  PatchCache                  0 /   131072",
252                 "  FontRenderer 0 A8      524288 /   524288",
253                 "  FontRenderer 0 RGBA         0 /        0",
254                 "  FontRenderer 0 total   524288 /   524288",
255                 "Other:",
256                 "  FboCache                    0 /        0",
257                 "Total memory usage:",
258                 "  8404288 bytes, 8.01 MB",
259                 "",
260                 "Profile data in ms:",
261                 "",
262                 "\tcom.google.android.videos/com.google.android.videos.pano.activity.PanoHomeActivity/android.view.ViewRootImpl@3d96e69 (visibility=8)",
263                 "Stats since: 6039768250261ns",
264                 "Total frames rendered: 107",
265                 "Janky frames: 42 (39.25%)",
266                 "90th percentile: 48ms",
267                 "95th percentile: 65ms",
268                 "99th percentile: 113ms",
269                 "Number Missed Vsync: 9",
270                 "Number High input latency: 0",
271                 "Number Slow UI thread: 28",
272                 "Number Slow bitmap uploads: 8",
273                 "Number Slow issue draw commands: 20",
274                 "",
275                 "View hierarchy:",
276                 "",
277                 "  com.google.android.videos/com.google.android.videos.pano.activity.PanoHomeActivity/android.view.ViewRootImpl@3d96e69",
278                 "  219 views, 173.57 kB of display lists",
279                 "",
280                 "",
281                 "Total ViewRootImpl: 1",
282                 "Total Views:        219",
283                 "Total DisplayList:  173.57 kB");
284 
285         GfxInfoItem item = new GfxInfoParser().parse(input);
286 
287         assertEquals(3, item.getPids().size());
288         assertEquals("com.google.android.leanbacklauncher", item.getName(844));
289         assertEquals(1690, item.getTotalFrames(844));
290         assertEquals(125, item.getJankyFrames(844));
291         assertEquals(13, item.getPrecentile90(844));
292         assertEquals(19, item.getPrecentile95(844));
293         assertEquals(48, item.getPrecentile99(844));
294         assertEquals("com.android.vending", item.getName(1881));
295         assertEquals(693, item.getTotalFrames(1881));
296         assertEquals(62, item.getJankyFrames(1881));
297         assertEquals(16, item.getPrecentile90(1881));
298         assertEquals(26, item.getPrecentile95(1881));
299         assertEquals(81, item.getPrecentile99(1881));
300         assertEquals("com.google.android.videos", item.getName(2931));
301         assertEquals(107, item.getTotalFrames(2931));
302         assertEquals(42, item.getJankyFrames(2931));
303         assertEquals(48, item.getPrecentile90(2931));
304         assertEquals(65, item.getPrecentile95(2931));
305         assertEquals(113, item.getPrecentile99(2931));
306     }
307 
308     /**
309      * Test gfxinfo output from L with single process.
310      * In L, gfxinfo does not contain Jank number information.
311      * This method tests that GfxInfoParser silently ignores such outputs.
312      */
testSingleProcessInL()313     public void testSingleProcessInL() {
314         List<String> input = Arrays.asList(
315                 "** Graphics info for pid 1924 [com.google.android.leanbacklauncher] **",
316                 "",
317                 "Caches:",
318                 "Current memory usage / total memory usage (bytes):",
319                 "  TextureCache         19521592 / 50331648",
320                 "  LayerCache           14745600 / 50331648 (numLayers = 5)",
321                 "    Layer size 512x512; isTextureLayer()=0; texid=392 fbo=0; refs=1",
322                 "    Layer size 512x448; isTextureLayer()=0; texid=377 fbo=0; refs=1",
323                 "    Layer size 1920x832; isTextureLayer()=0; texid=360 fbo=0; refs=1",
324                 "    Layer size 1920x512; isTextureLayer()=0; texid=14 fbo=0; refs=1",
325                 "    Layer size 1920x320; isTextureLayer()=0; texid=393 fbo=0; refs=1",
326                 "  Layers total   14745600 (numLayers = 5)",
327                 "  RenderBufferCache           0 /  8388608",
328                 "  GradientCache               0 /  1048576",
329                 "  PathCache             3370264 / 33554432",
330                 "  TessellationCache      194928 /  1048576",
331                 "  TextDropShadowCache         0 /  6291456",
332                 "  PatchCache                  0 /   131072",
333                 "  FontRenderer 0 A8     1048576 /  1048576",
334                 "  FontRenderer 0 RGBA         0 /        0",
335                 "  FontRenderer 0 total  1048576 /  1048576",
336                 "Other:",
337                 "  FboCache                    0 /        0",
338                 "Total memory usage:",
339                 "  38880960 bytes, 37.08 MB",
340                 "",
341                 "Profile data in ms:",
342                 "",
343                 "\tcom.google.android.leanbacklauncher/com.google.android.leanbacklauncher.MainActivity/android.view.ViewRootImpl@355a7923 (visibility=0)",
344                 "View hierarchy:",
345                 "",
346                 "  com.google.android.leanbacklauncher/com.google.android.leanbacklauncher.MainActivity/android.view.ViewRootImpl@355a7923",
347                 "  142 views, 136.96 kB of display lists",
348                 "",
349                 "",
350                 "Total ViewRootImpl: 1",
351                 "Total Views:        142",
352                 "Total DisplayList:  136.96 kB");
353 
354         GfxInfoItem item = new GfxInfoParser().parse(input);
355 
356         assertEquals(0, item.getPids().size());
357     }
358 }
359