Python小工具-查看内存和CPU

import 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)

猜你喜欢

转载自www.cnblogs.com/jiablogs/p/11135588.html