Android CPU Performance Testing Methods
This article explains three Android CPU performance testing techniques—using adb dumpsys cpuinfo, reading /proc/pid/stat, and employing the top command—detailing their procedures, advantages, limitations, and how to aggregate per‑process data for accurate app‑level metrics.
Performance testing is a crucial module for mobile applications, focusing on metrics such as CPU, memory, battery, GPU, FPS, network traffic, and temperature.
CPU performance testing can be performed using three main approaches on Android devices.
1. Using adb shell dumpsys cpuinfo – this command provides per‑PID CPU usage, where the first column is the usage percentage, the second column the PID/package name, and the third column detailed usage. It is easy to use but has high latency; the data may be up to 90 seconds old.
2. Reading /proc/pid/stat – the /proc virtual filesystem exposes kernel data. The /proc/stat file gives overall CPU times (user, nice, system, idle, iowait, irq, softirq) in jiffies. By reading the 14th and 15th fields of /proc/pid/stat (utime and stime) you can compute a process’s CPU time and, with a previous snapshot, calculate the CPU usage percentage. This method may encounter permission‑denied errors and requires sequential reads, which can affect timing consistency.
3. Using the Linux top command – adb shell top displays a table that includes PID, CPU %, VSS, RSS, etc. Common options are -m (number of processes), -n (refresh count), -d (interval), and -s (sort column). Because the column order can vary across devices, you should first run top -b -n 1 to detect the column containing CPU % and then parse that column. The command returns CPU usage for each process; to obtain the total usage of an app you must sum the values of all its processes, which can be identified by the shared UID assigned to the app.
By periodically executing the chosen method and aggregating the results, you can obtain reliable CPU performance metrics for Android applications.
Author : Hong Zhiyuan, Senior Test Development Engineer at Baidu Platform Testing Department, creator of SmartMonkey, Android hybrid script testing service, and Android test script recording tool.
Recruitment notice : Looking for experienced writers in mobile testing to submit original or translated articles; compensation and reputation offered. Contact: [email protected].
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
