标签:stp min ESS cmd命令 read == getc lda save
获取数据
adb shell "dumpsys meminfo | grep com.example.shineapp"
import os import time import csv #控制类 class Controller(object): def __init__(self,count): self.counter = count self.alldata = [("timestamp","cpustatus")] #单次测试过程 def testprocess(self): cpuvalue = 0 result = os.popen(‘adb shell "dumpsys meminfo | grep com.example.shineapp"‘) #双引号不能同时使用 for line in result.readlines(): cpuvalue = line.split(":")[0] currenttime = self.getCurrentTime() self.alldata.append((currenttime,cpuvalue)) #多次执行 def run(self): while self.counter > 0 : self.testprocess() self.counter = self.counter-1 time.sleep(5) #采集的时间间隔 #获取当前时间戳 def getCurrentTime(self): currenttime = time.strftime("%Y-%m-%d %H:%M:%S") return currenttime #数据存储 def SaveDataToCsv(self): csvfile = open("cpustatus.csv","wb") writer = csv.writer(csvfile) writer.writerows(self.alldata) csvfile.close() if __name__ == ‘__main__‘: controller = Controller(10) controller.run() controller.SaveDataToCsv()
标签:stp min ESS cmd命令 read == getc lda save
原文地址:https://www.cnblogs.com/lexus168/p/12690858.html