-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.py
More file actions
41 lines (34 loc) · 1.67 KB
/
command.py
File metadata and controls
41 lines (34 loc) · 1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# _*_ coding=utf-8 _*_
import sys
import os
import time
import subprocess
__author__ = 'patrick'
def now_time():
localtime = time.asctime(time.localtime(time.time()))
time_array = localtime.split(" ")[3].split(":")
print time_array
return time_array[0] + '_' + time_array[1] + '_' + time_array[2]
def write_log(waittime, package_name):
try:
subprocess.Popen("adb shell top >App_cpu_%s.txt" % now_time(), shell=True)
subprocess.Popen("adb logcat | grep ActivityManager >Start_Time_%s.txt" % now_time(), shell=True)
subprocess.Popen("adb logcat | grep GC >GC_Data_%s.txt" % now_time(), shell=True)
subprocess.Popen("adb shell dumpsys meminfo %s >Meminfo_%s.txt" % (package_name, now_time()), shell=True)
subprocess.Popen(
"adb logcat -v time *:E | grep com.alipay.m.portaltrafficeTest >NetWorkFile_%s.txt" % now_time(),
shell=True)
subprocess.Popen("adb logcat -v time *:E | grep battery >batteryFile_%s.txt" % now_time(), shell=True)
print '日志正在记录中。。。请稍后'
print '各个界面启动时间正在记录。。。请稍后'
print '应用每个功能cpu占用率正在记录。。。请稍后'
print '应用GC回收和使用时间正在记录。。。请稍后'
print '应用内存正在记录。。。请稍后'
print '应用网络数据正在记录。。。请稍后'
print '应用电量数据正在记录。。。请稍后'
time.sleep(float(waittime) * 1)
except KeyboardInterrupt:
print '报告正在生成'
os.system('adb kill-server')
if __name__ == '__main__':
write_log(sys.argv[1], sys.argv[2])