MCPcopy Index your code
hub / github.com/callstack/agent-device / parseAndroidCpuInfoSample

Function parseAndroidCpuInfoSample

src/platforms/android/perf.ts:212–242  ·  view source on GitHub ↗
(
  stdout: string,
  packageName: string,
  measuredAt: string,
)

Source from the content-addressed store, hash-verified

210}
211
212function parseAndroidCpuInfoSample(
213 stdout: string,
214 packageName: string,
215 measuredAt: string,
216): AndroidCpuPerfSample {
217 const matchedProcesses = new Set<string>();
218 let usagePercent = 0;
219
220 for (const line of splitNonEmptyTrimmedLines(stdout)) {
221 const match = line.match(/^([0-9]+(?:\.[0-9]+)?)%\s+\d+\/([^\s]+):\s/);
222 if (!match) continue;
223
224 const percentToken = match[1];
225 const processName = match[2];
226 if (percentToken === undefined || processName === undefined) continue;
227 const percent = Number(percentToken);
228 if (!Number.isFinite(percent) || !matchesAndroidPackageProcess(processName, packageName)) {
229 continue;
230 }
231
232 usagePercent += percent;
233 matchedProcesses.add(processName);
234 }
235
236 return {
237 usagePercent: roundPercent(usagePercent),
238 measuredAt,
239 method: ANDROID_CPU_SAMPLE_METHOD,
240 matchedProcesses: [...matchedProcesses],
241 };
242}
243
244export function parseAndroidMemInfoSample(
245 stdout: string,

Callers 1

sampleAndroidCpuPerfFunction · 0.85

Calls 4

roundPercentFunction · 0.90
isFiniteMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…