风流不在谈锋胜,袖手无言味最长。这篇文章主要讲述APP专项测试2 -- CPUcmd命令及脚本相关的知识,希望能为你提供帮助。
获取数据
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 = https://www.songbingjia.com/android/[("timestamp","cpustatus")]#单次测试过程 def testprocess(self): cpuvalue = https://www.songbingjia.com/android/0 result = os.popen(‘adb shell"dumpsys meminfo | grep com.example.shineapp"‘)#双引号不能同时使用 for line in result.readlines(): cpuvalue = https://www.songbingjia.com/android/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()
【APP专项测试2 -- CPUcmd命令及脚本】
推荐阅读
- 源码编译opencv的安卓Android库
- BadMethodCallException: Call to undefined method AppModelsArticle::setContainer()
- Ten Trending Applications of Artificial Intelligence
- APP自动化 -- 坐标获取和点击
- APP自动化--获取driver
- 移动端App自动化踩坑记录
- APP自动化 -- 获取toast元素的文本内容
- APP自动化 -- 框架
- APP自动化 -- MobileBy