性能获取办法 appium+webview context + execute script +perfmance api appium/selenium的ExecuteScript Api 注入js: return JSON.stringify(window.performance.timing) JSON.stringify(window.performance.getEntriesByName(document.querySele
性能获取办法
appium+webview context + execute script +perfmance api
appium/selenium的ExecuteScript Api
注入js:
return JSON.stringify(window.performance.timing)
JSON.stringify(window.performance.getEntriesByName(document.querySelector("img").src[0],null,2)
{ "name": "https://testerhome.com/system/letter_avatars/2/A/226_95_81/64.png", "entryType": "resource", "startTime": 277.4149999895599, "duration": 0, "initiatorType": "img", "nextHopProtocol": "", "workerStart": 0, "redirectStart": 0, "redirectEnd": 0, "fetchStart": 277.4149999895599, "domainLookupStart": 277.4149999895599, "domainLookupEnd": 277.4149999895599, "connectStart": 277.4149999895599, "connectEnd": 277.4149999895599, "secureConnectionStart": 0, "requestStart": 277.4149999895599, "responseStart": 277.4149999895599, "responseEnd": 277.4149999895599, "transferSize": 0, "encodedBodySize": 0, "decodedBodySize": 0, "serverTiming": [] }
performance(){ username=$(adb shell ps | grep $1 | awk '{print $1}') echo "for i in \$(seq 1 60);do top -u $username -o %CPU,%MEM,RES,CMDLINE -b -d 1 -n 1 -q ;done" > /tmp/p.sh adb push /tmp/p.sh /data/local/tmp/ adb shell sh /data/local/tmp/p.sh } performance com.xueqiu.android %CUP:cup使用率 %MEM:内存占用率 RES:申请使用的内存(进程占用的物理内存) SHR:进程使用的共享内存
获取详细内存
adb shell dumpsys meminfo com.xueqiu.android | grep "Native Heap" | head -1
pss:按比例共享内存(实际内存+部分共享内存)
Private Dirty:仅分配给您的应用堆的实际RAM 用来判断内存泄漏,如果内存泄漏,这个值会变大
手机端的性能主要是:耗电量,内存泄漏,cpu,卡顿,崩溃
Applications Memory Usage (in Kilobytes): Uptime: 59067939 Realtime: 59067939 ** MEMINFO in pid 13059 [com.xueqiu.android] ** Pss Private Private SwapPss Heap Heap Heap Total Dirty Clean Dirty Size Alloc Free ------ ------ ------ ------ ------ ------ ------ Native Heap 83864 83636 0 0 114816 100386 14429 Dalvik Heap 17536 17512 0 0 24391 18247 6144 Dalvik Other 6872 6872 0 0 Stack 1936 1936 0 0 Ashmem 6409 128 0 0 Other dev 17 0 16 0 .so mmap 3697 256 772 0 .apk mmap 17175 100 7372 0 .ttf mmap 117 0 0 0 .dex mmap 38235 8 34160 0 .oat mmap 4485 0 1048 0 .art mmap 2470 2144 12 0 Other mmap 7267 4 4608 0 Unknown 1600 1600 0 0 TOTAL 191680 114196 47988 0 139207 118633 20573 App Summary Pss(KB) ------ Java Heap: 19668 Native Heap: 83636 Code: 43716 Stack: 1936 Graphics: 0 Private Other: 13228 System: 29496 TOTAL: 191680 TOTAL SWAP PSS: 0 Objects Views: 4988 ViewRootImpl: 1 AppContexts: 6 Activities: 3 Assets: 6 AssetManagers: 5 Local Binders: 51 Proxy Binders: 34 Parcel memory: 20 Parcel count: 82 Death Recipients: 2 OpenSSL Sockets: 4 WebViews: 4 SQL MEMORY_USED: 615 PAGECACHE_OVERFLOW: 120 MALLOC_SIZE: 117 DATABASES pgsz dbsz Lookaside(b) cache Dbname 4 32 43 1/1680/2 /data/user/0/com.xueqiu.android/databases/-1.db 4 52 109 3456/1891/9 /data/user/0/com.xueqiu.android/databases/sn_green_dao_db_v1_7966815868 4 52 109 108/1693/17 /data/user/0/com.xueqiu.android/databases/bugly_db_ Asset Allocations zip:/data/app/com.xueqiu.android-65ziHf1fRax35Q5gRDHdUA==/base.apk:/assets/fonts/DIN-Bold.otf: 28K zip:/data/app/com.xueqiu.android-65ziHf1fRax35Q5gRDHdUA==/base.apk:/assets/fonts/DIN-Medium.otf: 27K zip:/data/app/com.xueqiu.android-65ziHf1fRax35Q5gRDHdUA==/base.apk:/assets/fonts/DIN-Regular.otf: 27K
更多性能指标获取方法
adb shell dumpsys procstats --hours 3 进程统计 adb shell dumpsys meminfo package_name|pid [-d] 内存信息 adb shell dumpsys batterystats --charged package-name 电池状态 adb shell dumpsys netstats detail 网络统计 adb shell dumpsys gfxinfo package-name 有关与录制阶段期间发生的动画帧相关的性能信息