python获取安卓app性能参数并绘图,,from matpl
python获取安卓app性能参数并绘图,,from matpl
from matplotlib import pyplot as pltfrom matplotlib import animationimport os,re# import numpy as npdef getTotalPss(): lines=os.popen("adb shell dumpsys meminfo com.rn_kiosk").readlines() # print(lines) total="TOTAL" for line in lines: if re.findall(total,line): lis=line.split(‘ ‘) # print(lis) while ‘‘ in lis: lis.remove(‘‘) return lis[1] # print(lis[1])def getCpu(): li = os.popen("adb shell top -m 100 -n 1 -s cpu").readlines() name = "com.rn_kiosk" for line in li: if re.findall(name,line): cuplist = line.split(" ") # print(cuplist) if cuplist[-1].strip() == ‘com.rn_kiosk‘: while ‘‘ in cuplist: # 将list中的空元素删除 cuplist.remove(‘‘) return(float(cuplist[2].strip(‘%‘))) #去掉百分号,返回一个float # print(cuplist) # print((cuplist[2].strip(‘%‘))) # getCpu()fig = plt.figure()ax1 = fig.add_subplot(2,1,1,xlim=(0, 1000), ylim=(0, 350))ax2 = fig.add_subplot(2,1,2,xlim=(0, 1000), ylim=(0, 100))line,= ax1.plot([], [], lw=2)line2,= ax2.plot([], [], lw=2)x=[]y=[]y2=[]def init(): line.set_data([], []) line2.set_data([], []) return line,line2def getx(): t = "0" return tdef animate(i): x.append(int(getx())+i) y.append(int(getTotalPss())/1024) y2.append(getCpu()) print(x,y) line.set_data(x,y) line2.set_data(x,y2) return line,line2anim1 = animation.FuncAnimation(fig, animate, init_func=init, frames=1000, interval=30)plt.show()
python获取安卓app性能参数并绘图
相关内容
- python -- 模块和包,,一. 模块 impo
- python web篇,,新建立一个虚拟环境,
- Python MQTT 实验,,Two client
- python从入门到掉坑,,python 从起步
- python中的return中用法总结,,第五题:自己实现一个
- python接口自动化框架_初级,,1、前提:pytho
- python/django-上传excel文件并用pandas处理,,html文件<fo
- python3 学习(2):在网站地图爬虫时的cannot use a strin
- 人生苦短,我学python之python+selenium 随机生成手机号码
- Python——处理json文件,,转载来源:https
评论关闭