Android App性能測试
一、内存
1、查看单个应用App最大内存限制
Command:adb shell “getprop|grep heapgrowthlimit”
C:\Users\hujiachun>adb shell "getprop|grep heapgrowthlimit" [dalvik.vm.heapgrowthlimit]: [128m]
128M是单个APP最大内存限制,假设Dalvik Heap 的Pss大于128。就会报内存溢出
2、监控某个App内存
Command:adb shell dumpsys meminfo com.meizu.mstore
C:\Users\hujiachun>adb shell dumpsys meminfo com.meizu.mstore Applications Memory Usage (kB): Uptime: 5159608 Realtime: 5159608 ** MEMINFO in pid 13914 [com.meizu.mstore] ** Pss Private Private Swapped Heap Heap Heap Total Dirty Clean Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ ------ Native Heap 0 0 0 0 28672 18939 9732 Dalvik Heap 45029 44068 0 0 60986 56981 4005 Dalvik Other 680 680 0 60 Stack 492 492 0 36 Other dev 6 0 4 0 .so mmap 2454 172 284 1728 .apk mmap 509 0 228 0 .ttf mmap 854 0 464 0 .dex mmap 6240 0 6236 0 .oat mmap 5925 0 2564 0 .art mmap 2951 1748 716 8 Other mmap 137 4 104 0 EGL mtrack 14960 14960 0 0 GL mtrack 59264 59264 0 0 Unknown 16331 16256 0 816 TOTAL 155832 137644 10600 2648 89658 75920 13737 Objects Views: 1242 ViewRootImpl: 1 AppContexts: 4 Activities: 1 Assets: 4 AssetManagers: 4 Local Binders: 31 Proxy Binders: 29 Parcel memory: 15 Parcel count: 60 Death Recipients: 1 OpenSSL Sockets: 0 SQL MEMORY_USED: 430 PAGECACHE_OVERFLOW: 116 MALLOC_SIZE: 62 DATABASES pgsz dbsz Lookaside(b) cache Dbname 4 20 83 210/52/9 /data/data/com.meizu.mstore/d atabases/UsageStats.db 4 24 18 0/42/1 /data/data/com.meizu.mstore/d atabases/download_task.db 4 24 50 1/43/2 /data/data/com.meizu.mstore/d atabases/download_app.db 4 24 18 0/42/1 /data/data/com.meizu.mstore/d atabases/Mstore_Recommend_db
能够通过过滤信息 得到Dalvik Heap 的Pss值。实时监控
二、CPU
Command:adb shell " dumpsys cpuinfo |grep com.meizu.mstore"
C:\Users\hujiachun>adb shell " dumpsys cpuinfo |grep com.meizu.mstore" 1.3% 18957/com.meizu.mstore: 1% user + 0.2% kernel / faults: 171 minor
1.3% 是总消耗CPU
user是用户消耗
kernel 是内核消耗