2、通過python指令碼呼叫adb命令
3、持續監控寫入txt檔案或者csv檔案中
adb監控記憶體命令
# adb監控記憶體變化
進行資料分析通過觀察,我們只需要提取出來結果的 native heap 和 dalvik heap,還有記憶體總和 total,接下來我們通過python把想要的資料提取出來
# coding:utf-8
import os
# 獲取**記憶體命令
adb =
'adb shell dumpsys meminfo com.taobao.taobao'
# 執行adb命令
result = os.popen(adb)
.read(
)# 以','進行分割
temp =
','.join(result.split())
# 獲取native值
native = temp.split(
'native,heap')[
1].split(
',')[1
]# 獲取dalvik值
dalvik = temp.split(
'dalvik,heap')[
1].split(
',')[1
]# 獲取total值
total = temp.split(
'total')[
1].split(
',')[1
]
這樣的話就把我們想要的資料提取出來了,可以中間加個等待時間,每幾秒提取一次資料,接下來我們呢進行對這些資料寫入csv檔案或者txt檔案中
首先我們建立乙個列表,把每次提取出來的資料放入到列表中,寫入csv檔案中
# coding:utf-8
import os
import time
import csv
alldata =[(
"native"
,"dalvik"
,"total")]
# 設定迴圈次數
count =
10while count >0:
lines = os.popen(
"adb shell dumpsys meminfo com.taobao.taobao"
) result = lines.read(
) temp =
','.join(result.split())
native_heap = temp.split(
'native,heap')[
1].split(
',')[1
]print
("native_heap:"
+str
(native_heap)
) dalvik_heap = temp.split(
'dalvik,heap')[
1].split(
',')[1
]print
("dalvik_heap:"
+str
(dalvik_heap)
) total = temp.split(
'total')[
1].split(
',')[1
]print
("total:"
+str
(total)
)[native_heap, dalvik_heap,total]
) count -=
1print
('還剩餘:%s次'
%count)
time.sleep(1)
# 等待時間
csvfile =
open
('test02.csv'
,'w'
,encoding=
'utf8'
,newline='')
writer = csv.writer(csvfile)
writer.writerows(alldata)
csvfile.close(
)
剩下的cpu,耗電量大家試著完成下,要記住耗電量不能通過usb的方式連線哈,要不然就會一直處於充電狀態
appium Android app資源監控
2 通過python指令碼呼叫adb命令 3 持續監控寫入txt檔案或者csv檔案中 adb監控記憶體命令 adb監控記憶體變化 進行資料分析 通過觀察,我們只需要提取出來結果的 native heap 和 dalvik heap,還有記憶體總和 total,接下來我們通過python把想要的資料提...
Linux 資源監控
網路資源監控 iftop 互動執行 iftop 按p顯示本機和目標伺服器的埠 按t切換顯示格式為2行 1行 只顯示傳送流量 只顯示接收流量 按b切換是否顯示平均流量圖形條 按b切換計算2秒或10秒或40秒內的平均流量 按t切換是否顯示每個連線的總流量 按l切換顯示畫面上邊的刻度 刻度不同,流量圖形條...
資源監控工具Munin
munin 是一款優秀的效能監控工具,採用client server模式,支援同時監控多個節點,並且以web的方式展現出來。munin 可監控伺服器的所有方面,包括最重要的cpu,memory,disk,io等等。同時支援監控多組伺服器,並以圖形化的方式展現出來。下圖為munin的監控cpu的圖形介...