-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmem.py
More file actions
35 lines (33 loc) · 1019 Bytes
/
mem.py
File metadata and controls
35 lines (33 loc) · 1019 Bytes
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
import subprocess
import time
import csv
import sys
import os
processName = sys.argv[1]
fileExists = True
fileName = 'gmail0'
while(fileExists):
if(os.path.isfile(fileName+'.csv')):
value = int(fileName[5:])
value = value + 1;
fileName = fileName[:5]
fileName = fileName+str(value)
print(fileName)
else:
fileExists = False
fileName = fileName+'.csv'
f = open(fileName,'w')
writer = csv.writer(f)
writer.writerow(['Time(s)','TOTAL PSS'])
currentTime = 0
startTime = round(time.time())
while(1):
value = subprocess.run(["adb","shell","dumpsys","meminfo",processName,"|","grep","TOTAL"],capture_output=True)
currentTime = round(time.time())
currentTime = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(currentTime))
ctime = currentTime.split()
valueList = str(value.stdout).split()
print(valueList[2])
totalPSS = int(valueList[2])/ 1024
writer.writerow([ctime[1],totalPSS])
time.sleep(0.5)