Python小工具-查看内存和CPU
2020-12-13 05:12
标签:com pack bsp stderr inf pos 工具 txt cas Python小工具-查看内存和CPU 标签:com pack bsp stderr inf pos 工具 txt cas 原文地址:https://www.cnblogs.com/jiablogs/p/11135588.htmlimport subprocess
from time import sleep
package = ‘com.wangpos.by.cashier3‘
memory_name = ‘adb shell dumpsys meminfo {} | findstr "Pss"‘.format(package)
memory = ‘adb shell dumpsys meminfo {} | findstr "Pss"‘.format(package)
log_name = open(‘log.txt‘, ‘w‘)
for i in range(100000):
subprocess.Popen(memory, stderr=log_name, stdout=subprocess.PIPE,shell=True)
sleep(5)
cpu = ‘adb shell top -n 1 | findstr "PID"‘
cpu_exec = ‘adb shell top -n 1 | findstr {package}‘.format(package=package)
for i in range(10000):
subprocess.Popen(cpu_exec, stderr=log_name,stdout=subprocess.PIPE)
下一篇:矩阵的运算:Python语言实现