Q16 of 26 · Mobile QA

How do you measure and validate performance and battery consumption in a mobile app?

Mobile QAMidmobileperformancebatteryandroid-profilerinstrumentsadbappium

Short answer

Short answer: Use Android Profiler (or adb shell dumpsys) for memory, CPU, and battery stats; Instruments on iOS. Establish a baseline on a known build, run a representative user journey, and assert regressions in CI by comparing metrics against the baseline.

Detail

Android: the Android Profiler in Android Studio provides real-time CPU, memory, network, and battery usage graphs. For CI-suitable headless measurement, use ADB shell commands: adb shell dumpsys meminfo com.example.myapp for memory, adb shell dumpsys batterystats for battery consumption since last charge, and adb shell top -n 1 | grep myapp for CPU. Appium's getPerformanceData command wraps some of these for programmatic access.

iOS: Instruments (part of Xcode) provides Time Profiler, Allocations, and Energy Log instruments. For CI, XCTest's XCTMetric API lets you measure memory, CPU, disk writes, and app-launch time as part of an XCTest Performance Test — these run on the simulator and produce baseline-comparable results out of the box.

The approach: define a representative journey (e.g. browse 20 product listings, add to cart, proceed to checkout), run it on a baseline build, record the metrics, and set regression thresholds (e.g. memory growth under 5 MB, CPU under 40% average). Run the same journey on each build and fail CI if thresholds are exceeded.

Battery testing specifically: run a journey repeatedly for 10 minutes on a real device with the screen on, record battery-stats diff, and compare against baseline. Watch for wakelock leaks — background processes that prevent the device from sleeping.

// WHAT INTERVIEWERS LOOK FOR

Knows platform-specific tooling (Profiler/Instruments), describes a baseline-and-compare methodology, and mentions CI integration via headless tooling rather than only manual profiling.