magnax 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- magnax/__init__.py +3 -0
- magnax/__main__.py +25 -0
- magnax/debug.py +65 -0
- magnax/public/__init__.py +1 -0
- magnax/public/adb/linux/adb +0 -0
- magnax/public/adb/linux_arm/adb +0 -0
- magnax/public/adb/mac/adb +0 -0
- magnax/public/adb/windows/AdbWinApi.dll +0 -0
- magnax/public/adb/windows/AdbWinUsbApi.dll +0 -0
- magnax/public/adb/windows/adb.exe +0 -0
- magnax/public/adb.py +96 -0
- magnax/public/android_fps.py +750 -0
- magnax/public/apm.py +1306 -0
- magnax/public/apm_pk.py +184 -0
- magnax/public/common.py +1598 -0
- magnax/public/config.json +1 -0
- magnax/public/ios_perf_adapter.py +790 -0
- magnax/public/report_template/android.html +526 -0
- magnax/public/report_template/ios.html +482 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinUsbApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/SDL2.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/adb.exe +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/avcodec-60.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/avformat-60.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/avutil-58.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/icon.png +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/libusb-1.0.dll +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/open_a_terminal_here.bat +1 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-console.bat +2 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-noconsole.vbs +7 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-server +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy.exe +0 -0
- magnax/public/scrcpy/scrcpy-win32-v2.4/swresample-4.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinUsbApi.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/SDL2.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/avformat-60.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/avutil-58.dll +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/open_a_terminal_here.bat +1 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-noconsole.vbs +7 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-server +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy.exe +0 -0
- magnax/public/scrcpy/scrcpy-win64-v2.4/swresample-4.dll +0 -0
- magnax/static/css/highlight.min.css +9 -0
- magnax/static/css/magnax-dark-theme.css +1237 -0
- magnax/static/css/select2-bootstrap-5-theme.min.css +3 -0
- magnax/static/css/select2-bootstrap-5-theme.rtl.min.css +3 -0
- magnax/static/css/select2.min.css +1 -0
- magnax/static/css/sweetalert2.min.css +1 -0
- magnax/static/css/tabler.demo.min.css +9 -0
- magnax/static/css/tabler.min.css +14 -0
- magnax/static/image/500.png +0 -0
- magnax/static/image/avatar.png +0 -0
- magnax/static/image/empty.png +0 -0
- magnax/static/image/readme/home.png +0 -0
- magnax/static/image/readme/pk.png +0 -0
- magnax/static/js/apexcharts.js +14 -0
- magnax/static/js/gray.js +16 -0
- magnax/static/js/highlight.min.js +1173 -0
- magnax/static/js/highstock.js +803 -0
- magnax/static/js/html2canvas.min.js +20 -0
- magnax/static/js/jquery.min.js +2 -0
- magnax/static/js/magnax-chart-theme.js +492 -0
- magnax/static/js/select2.min.js +2 -0
- magnax/static/js/sweetalert2.min.js +1 -0
- magnax/static/js/tabler.demo.min.js +9 -0
- magnax/static/js/tabler.min.js +9 -0
- magnax/static/logo/logo.png +0 -0
- magnax/templates/404.html +30 -0
- magnax/templates/analysis.html +1375 -0
- magnax/templates/analysis_compare.html +600 -0
- magnax/templates/analysis_pk.html +680 -0
- magnax/templates/base.html +365 -0
- magnax/templates/index.html +2471 -0
- magnax/templates/pk.html +743 -0
- magnax/templates/report.html +416 -0
- magnax/view/__init__.py +1 -0
- magnax/view/apis.py +952 -0
- magnax/view/pages.py +146 -0
- magnax/web.py +345 -0
- magnax-1.0.0.dist-info/METADATA +242 -0
- magnax-1.0.0.dist-info/RECORD +87 -0
- magnax-1.0.0.dist-info/WHEEL +5 -0
- magnax-1.0.0.dist-info/entry_points.txt +2 -0
- magnax-1.0.0.dist-info/licenses/LICENSE +21 -0
- magnax-1.0.0.dist-info/top_level.txt +1 -0
magnax/public/apm_pk.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import datetime
|
|
2
|
+
import re
|
|
3
|
+
import os
|
|
4
|
+
import time
|
|
5
|
+
from solox.public.adb import adb
|
|
6
|
+
from solox.public.common import Devices, File
|
|
7
|
+
from solox.public.android_fps import FPSMonitor, TimeUtils
|
|
8
|
+
|
|
9
|
+
d = Devices()
|
|
10
|
+
f = File()
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class CPU_PK:
|
|
14
|
+
|
|
15
|
+
def __init__(self, pkgNameList: list, deviceId1, deviceId2):
|
|
16
|
+
self.pkgNameList = pkgNameList
|
|
17
|
+
self.deviceId1 = deviceId1
|
|
18
|
+
self.deviceId2 = deviceId2
|
|
19
|
+
|
|
20
|
+
def getprocessCpuStat(self, pkgName, deviceId):
|
|
21
|
+
"""get the cpu usage of a process at a certain time"""
|
|
22
|
+
pid = pid = d.getPid(pkgName=pkgName, deviceId=deviceId)[0].split(':')[0]
|
|
23
|
+
cmd = 'cat /proc/{}/stat'.format(pid)
|
|
24
|
+
result = adb.shell(cmd=cmd, deviceId=deviceId)
|
|
25
|
+
r = re.compile("\\s+")
|
|
26
|
+
toks = r.split(result)
|
|
27
|
+
processCpu = float(toks[13]) + float(toks[14]) + float(toks[15]) + float(toks[16])
|
|
28
|
+
return processCpu
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def getTotalCpuStat(self, deviceId):
|
|
32
|
+
"""get the total cpu usage at a certain time"""
|
|
33
|
+
cmd = 'cat /proc/stat |{} ^cpu'.format(d.filterType())
|
|
34
|
+
result = adb.shell(cmd=cmd, deviceId=deviceId)
|
|
35
|
+
totalCpu = 0
|
|
36
|
+
lines = result.split('\n')
|
|
37
|
+
lines.pop(0)
|
|
38
|
+
for line in lines:
|
|
39
|
+
toks = line.split()
|
|
40
|
+
if toks[1] in ['', ' ']:
|
|
41
|
+
toks.pop(1)
|
|
42
|
+
for i in range(1, 8):
|
|
43
|
+
totalCpu += float(toks[i])
|
|
44
|
+
return float(totalCpu)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def getIdleCpuStat(self, deviceId):
|
|
48
|
+
"""get the idle cpu usage at a certain time"""
|
|
49
|
+
cmd = 'cat /proc/stat |{} ^cpu'.format(d.filterType())
|
|
50
|
+
result = adb.shell(cmd=cmd, deviceId=deviceId)
|
|
51
|
+
r = re.compile(r'(?<!cpu)\d+')
|
|
52
|
+
toks = r.findall(result)
|
|
53
|
+
IdleCpu = float(toks[4])
|
|
54
|
+
return IdleCpu
|
|
55
|
+
|
|
56
|
+
def getAndroidCpuRate(self):
|
|
57
|
+
"""get the Android cpu rate of a process"""
|
|
58
|
+
processCpuTime1_first = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
|
|
59
|
+
totalCpuTime1_first = self.getTotalCpuStat(deviceId=self.deviceId1)
|
|
60
|
+
time.sleep(0.5)
|
|
61
|
+
processCpuTime1_second = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
|
|
62
|
+
totalCpuTime1_second = self.getTotalCpuStat(deviceId=self.deviceId1)
|
|
63
|
+
|
|
64
|
+
if len(self.pkgNameList) == 1:
|
|
65
|
+
processCpuTime2_first = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId2)
|
|
66
|
+
totalCpuTime2_first = self.getTotalCpuStat(deviceId=self.deviceId2)
|
|
67
|
+
time.sleep(0.5)
|
|
68
|
+
processCpuTime2_second = self.getprocessCpuStat(pkgName=self.pkgNameList[0], deviceId=self.deviceId2)
|
|
69
|
+
totalCpuTime2_second = self.getTotalCpuStat(deviceId=self.deviceId2)
|
|
70
|
+
else:
|
|
71
|
+
processCpuTime2_first = self.getprocessCpuStat(pkgName=self.pkgNameList[1], deviceId=self.deviceId2)
|
|
72
|
+
totalCpuTime2_first = self.getTotalCpuStat(deviceId=self.deviceId2)
|
|
73
|
+
time.sleep(0.5)
|
|
74
|
+
processCpuTime2_second = self.getprocessCpuStat(pkgName=self.pkgNameList[1], deviceId=self.deviceId2)
|
|
75
|
+
totalCpuTime2_second = self.getTotalCpuStat(deviceId=self.deviceId2)
|
|
76
|
+
|
|
77
|
+
appCpuRate1 = round(float((processCpuTime1_second - processCpuTime1_first) / (totalCpuTime1_second - totalCpuTime1_first) * 100), 2)
|
|
78
|
+
appCpuRate2 = round(float((processCpuTime2_second - processCpuTime2_first) / (totalCpuTime2_second - totalCpuTime2_first) * 100), 2)
|
|
79
|
+
apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
|
|
80
|
+
f.add_log(os.path.join(f.report_dir, 'cpu_app1.log'), apm_time, appCpuRate1)
|
|
81
|
+
f.add_log(os.path.join(f.report_dir, 'cpu_app2.log'), apm_time, appCpuRate2)
|
|
82
|
+
return appCpuRate1, appCpuRate2
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class MEM_PK:
|
|
86
|
+
def __init__(self, pkgNameList: list, deviceId1, deviceId2):
|
|
87
|
+
self.pkgNameList = pkgNameList
|
|
88
|
+
self.deviceId1 = deviceId1
|
|
89
|
+
self.deviceId2 = deviceId2
|
|
90
|
+
|
|
91
|
+
def getAndroidMemory(self, pkgName, deviceId):
|
|
92
|
+
"""Get the Android memory ,unit:MB"""
|
|
93
|
+
pid = d.getPid(pkgName=pkgName, deviceId=deviceId)[0].split(':')[0]
|
|
94
|
+
cmd = 'dumpsys meminfo {}'.format(pid)
|
|
95
|
+
output = adb.shell(cmd=cmd, deviceId=deviceId)
|
|
96
|
+
m_total = re.search(r'TOTAL\s*(\d+)', output)
|
|
97
|
+
totalPass = round(float(float(m_total.group(1))) / 1024, 2)
|
|
98
|
+
return totalPass
|
|
99
|
+
|
|
100
|
+
def getProcessMemory(self):
|
|
101
|
+
"""Get the app memory"""
|
|
102
|
+
if len(self.pkgNameList) == 1:
|
|
103
|
+
totalPass1 = self.getAndroidMemory(self.pkgNameList[0], self.deviceId1)
|
|
104
|
+
totalPass2 = self.getAndroidMemory(self.pkgNameList[0], self.deviceId2)
|
|
105
|
+
else:
|
|
106
|
+
totalPass1 = self.getAndroidMemory(self.pkgNameList[0], self.deviceId1)
|
|
107
|
+
totalPass2 = self.getAndroidMemory(self.pkgNameList[1], self.deviceId2)
|
|
108
|
+
apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
|
|
109
|
+
f.add_log(os.path.join(f.report_dir, 'mem1.log'), apm_time, totalPass1)
|
|
110
|
+
f.add_log(os.path.join(f.report_dir, 'mem2.log'), apm_time, totalPass2)
|
|
111
|
+
|
|
112
|
+
return totalPass1, totalPass2
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class Flow_PK:
|
|
116
|
+
|
|
117
|
+
def __init__(self, pkgNameList: list, deviceId1, deviceId2):
|
|
118
|
+
self.pkgNameList = pkgNameList
|
|
119
|
+
self.deviceId1 = deviceId1
|
|
120
|
+
self.deviceId2 = deviceId2
|
|
121
|
+
|
|
122
|
+
def getAndroidNet(self, pkgName, deviceId):
|
|
123
|
+
"""Get Android upflow and downflow data, unit:KB"""
|
|
124
|
+
pid = d.getPid(pkgName=pkgName, deviceId=deviceId)[0].split(':')[0]
|
|
125
|
+
cmd = 'cat /proc/{}/net/dev |{} wlan0'.format(pid, d.filterType())
|
|
126
|
+
output_pre = adb.shell(cmd=cmd, deviceId=deviceId)
|
|
127
|
+
m_pre = re.search(r'wlan0:\s*(\d+)\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*(\d+)', output_pre)
|
|
128
|
+
sendNum_pre = round(float(float(m_pre.group(2)) / 1024), 2)
|
|
129
|
+
recNum_pre = round(float(float(m_pre.group(1)) / 1024), 2)
|
|
130
|
+
time.sleep(0.5)
|
|
131
|
+
output_final = adb.shell(cmd=cmd, deviceId=deviceId)
|
|
132
|
+
m_final = re.search(r'wlan0:\s*(\d+)\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*\d+\s*(\d+)', output_final)
|
|
133
|
+
sendNum_final = round(float(float(m_final.group(2)) / 1024), 2)
|
|
134
|
+
recNum_final = round(float(float(m_final.group(1)) / 1024), 2)
|
|
135
|
+
sendNum = round(float(sendNum_final - sendNum_pre), 2)
|
|
136
|
+
recNum = round(float(recNum_final - recNum_pre), 2)
|
|
137
|
+
network = round(float(sendNum + recNum), 2)
|
|
138
|
+
return network
|
|
139
|
+
|
|
140
|
+
def getNetWorkData(self):
|
|
141
|
+
"""Get the upflow and downflow data, unit:KB"""
|
|
142
|
+
if len(self.pkgNameList) == 1:
|
|
143
|
+
network1 = self.getAndroidNet(self.pkgNameList[0], self.deviceId1)
|
|
144
|
+
network2 = self.getAndroidNet(self.pkgNameList[0], self.deviceId2)
|
|
145
|
+
else:
|
|
146
|
+
network1 = self.getAndroidNet(self.pkgNameList[0], self.deviceId1)
|
|
147
|
+
network2 = self.getAndroidNet(self.pkgNameList[1], self.deviceId2)
|
|
148
|
+
apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
|
|
149
|
+
f.add_log(os.path.join(f.report_dir, 'network1.log'), apm_time, network1)
|
|
150
|
+
f.add_log(os.path.join(f.report_dir, 'network2.log'), apm_time, network2)
|
|
151
|
+
return network1, network2
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
class FPS_PK:
|
|
155
|
+
|
|
156
|
+
def __init__(self, pkgNameList: list, deviceId1, deviceId2, surfaceview=True):
|
|
157
|
+
self.pkgNameList = pkgNameList
|
|
158
|
+
self.deviceId1 = deviceId1
|
|
159
|
+
self.deviceId2 = deviceId2
|
|
160
|
+
self.surfaceview = surfaceview
|
|
161
|
+
|
|
162
|
+
def getAndroidFps(self, deviceId, pkgName):
|
|
163
|
+
"""get Android Fps, unit:HZ"""
|
|
164
|
+
monitors = FPSMonitor(device_id=deviceId, package_name=pkgName, frequency=1,
|
|
165
|
+
surfaceview=self.surfaceview, start_time=TimeUtils.getCurrentTimeUnderline())
|
|
166
|
+
monitors.start()
|
|
167
|
+
fps, jank = monitors.stop()
|
|
168
|
+
return fps
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def getFPS(self):
|
|
172
|
+
"""get fps"""
|
|
173
|
+
if len(self.pkgNameList) == 1:
|
|
174
|
+
fps1 = self.getAndroidFps(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
|
|
175
|
+
fps2 = self.getAndroidFps(pkgName=self.pkgNameList[0], deviceId=self.deviceId2)
|
|
176
|
+
else:
|
|
177
|
+
fps1 = self.getAndroidFps(pkgName=self.pkgNameList[0], deviceId=self.deviceId1)
|
|
178
|
+
fps2 = self.getAndroidFps(pkgName=self.pkgNameList[1], deviceId=self.deviceId2)
|
|
179
|
+
apm_time = datetime.datetime.now().strftime('%H:%M:%S.%f')
|
|
180
|
+
f.add_log(os.path.join(f.report_dir, 'fps1.log'), apm_time, fps1)
|
|
181
|
+
f.add_log(os.path.join(f.report_dir, 'fps2.log'), apm_time, fps2)
|
|
182
|
+
return fps1, fps2
|
|
183
|
+
|
|
184
|
+
|