Skip to content

Commit 0c7e48d

Browse files
authored
feat: add Android frame health perf metrics (#474)
1 parent f7c8f45 commit 0c7e48d

17 files changed

Lines changed: 1509 additions & 199 deletions

src/__tests__/cli-perf.test.ts

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import { test } from 'vitest';
2+
import assert from 'node:assert/strict';
3+
import { runCliCapture } from './cli-capture.ts';
4+
5+
test('perf prints compact platform-independent frame health summary by default', async () => {
6+
const result = await runCliCapture(['perf'], async () => ({
7+
ok: true,
8+
data: {
9+
session: 'android-perf',
10+
platform: 'android',
11+
device: 'Pixel',
12+
metrics: {
13+
fps: {
14+
available: true,
15+
droppedFramePercent: 7.6,
16+
droppedFrameCount: 637,
17+
totalFrameCount: 8407,
18+
sampleWindowMs: 615390,
19+
method: 'adb-shell-dumpsys-gfxinfo-framestats',
20+
source: 'android-gfxinfo-summary',
21+
worstWindows: [
22+
{
23+
startOffsetMs: 1200,
24+
endOffsetMs: 2100,
25+
missedDeadlineFrameCount: 8,
26+
worstFrameMs: 84,
27+
},
28+
],
29+
},
30+
memory: {
31+
available: true,
32+
totalPssKb: 250000,
33+
},
34+
cpu: {
35+
available: true,
36+
usagePercent: 13,
37+
},
38+
},
39+
},
40+
}));
41+
42+
assert.equal(result.code, null);
43+
const lines = result.stdout.trimEnd().split('\n');
44+
assert.equal(lines[0], 'Frame health: dropped 7.6% (637/8407 frames) window 10m 15s');
45+
assert.equal(lines[1], 'Worst windows:');
46+
assert.equal(lines[2], '- +1s-+2s: 8 missed-deadline frames, worst 84ms');
47+
assert.doesNotMatch(result.stdout, /android|Pixel|memory|cpu|gfxinfo/i);
48+
});
49+
50+
test('perf prints unavailable frame health reason by default', async () => {
51+
const result = await runCliCapture(['perf'], async () => ({
52+
ok: true,
53+
data: {
54+
metrics: {
55+
fps: {
56+
available: false,
57+
reason: 'Dropped-frame sampling is currently available only on Android.',
58+
},
59+
},
60+
},
61+
}));
62+
63+
assert.equal(result.code, null);
64+
assert.equal(
65+
result.stdout,
66+
'Frame health: unavailable - Dropped-frame sampling is currently available only on Android.\n',
67+
);
68+
});
69+
70+
test('perf prints compact CPU and memory summary when frame health is unavailable', async () => {
71+
const result = await runCliCapture(['perf'], async () => ({
72+
ok: true,
73+
data: {
74+
metrics: {
75+
fps: {
76+
available: false,
77+
reason: 'Dropped-frame sampling is currently available only on Android.',
78+
},
79+
memory: {
80+
available: true,
81+
residentMemoryKb: 250000,
82+
},
83+
cpu: {
84+
available: true,
85+
usagePercent: 12.5,
86+
},
87+
},
88+
},
89+
}));
90+
91+
assert.equal(result.code, null);
92+
assert.equal(result.stdout, 'Performance: CPU 12.5%, memory 244MB\n');
93+
});

0 commit comments

Comments
 (0)