APP启动时间统计
启动10次app
import subprocess,time
from pyecharts.charts import *
current_activity = "com.v2ay.ang/.ui.MainActivity"
cmd1 = "adb -s ANP4C20410007003 shell am start -S -W " + current_activity + " | findstr TotalTime"
print(cmd1) # adb -s ANP4C20410007003 shell am start -S -W com.v2ay.ang/.ui.MainActivity | findstr TotalTime
start_list = [] # ['第1次', '第2次', '第3次', '第4次', '第5次', '第6次', '第7次', '第8次', '第9次', '第10次']
time_list = [] # [' 263', ' 329', ' 263', ' 256', ' 262', ' 263', ' 275', ' 266', ' 258', ' 268']
for i in range(1, 11):
start_list.append('第{0}次'.format(i))
console = subprocess.getstatusoutput(cmd1)
total_time = list(console)[1].split(": ")[1]
time_list.append(total_time)
time.sleep(1)
print(time_list)
print(start_list)
line = (
Line().add_xaxis(start_list).add_yaxis('', time_list)
)
# line.render_notebook()
line.render()
绘成折线图
# 包名:com.v2ay.ang
清理缓存数据:adb shell pm clear com.v2ay.ang
停止进程:adb shell am force-stop com.v2ay.ang
获取数据:adb logcat |grep -i displayed