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.
Files changed (87) hide show
  1. magnax/__init__.py +3 -0
  2. magnax/__main__.py +25 -0
  3. magnax/debug.py +65 -0
  4. magnax/public/__init__.py +1 -0
  5. magnax/public/adb/linux/adb +0 -0
  6. magnax/public/adb/linux_arm/adb +0 -0
  7. magnax/public/adb/mac/adb +0 -0
  8. magnax/public/adb/windows/AdbWinApi.dll +0 -0
  9. magnax/public/adb/windows/AdbWinUsbApi.dll +0 -0
  10. magnax/public/adb/windows/adb.exe +0 -0
  11. magnax/public/adb.py +96 -0
  12. magnax/public/android_fps.py +750 -0
  13. magnax/public/apm.py +1306 -0
  14. magnax/public/apm_pk.py +184 -0
  15. magnax/public/common.py +1598 -0
  16. magnax/public/config.json +1 -0
  17. magnax/public/ios_perf_adapter.py +790 -0
  18. magnax/public/report_template/android.html +526 -0
  19. magnax/public/report_template/ios.html +482 -0
  20. magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinApi.dll +0 -0
  21. magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinUsbApi.dll +0 -0
  22. magnax/public/scrcpy/scrcpy-win32-v2.4/SDL2.dll +0 -0
  23. magnax/public/scrcpy/scrcpy-win32-v2.4/adb.exe +0 -0
  24. magnax/public/scrcpy/scrcpy-win32-v2.4/avcodec-60.dll +0 -0
  25. magnax/public/scrcpy/scrcpy-win32-v2.4/avformat-60.dll +0 -0
  26. magnax/public/scrcpy/scrcpy-win32-v2.4/avutil-58.dll +0 -0
  27. magnax/public/scrcpy/scrcpy-win32-v2.4/icon.png +0 -0
  28. magnax/public/scrcpy/scrcpy-win32-v2.4/libusb-1.0.dll +0 -0
  29. magnax/public/scrcpy/scrcpy-win32-v2.4/open_a_terminal_here.bat +1 -0
  30. magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-console.bat +2 -0
  31. magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-noconsole.vbs +7 -0
  32. magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-server +0 -0
  33. magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy.exe +0 -0
  34. magnax/public/scrcpy/scrcpy-win32-v2.4/swresample-4.dll +0 -0
  35. magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinApi.dll +0 -0
  36. magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinUsbApi.dll +0 -0
  37. magnax/public/scrcpy/scrcpy-win64-v2.4/SDL2.dll +0 -0
  38. magnax/public/scrcpy/scrcpy-win64-v2.4/avformat-60.dll +0 -0
  39. magnax/public/scrcpy/scrcpy-win64-v2.4/avutil-58.dll +0 -0
  40. magnax/public/scrcpy/scrcpy-win64-v2.4/open_a_terminal_here.bat +1 -0
  41. magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-noconsole.vbs +7 -0
  42. magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-server +0 -0
  43. magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy.exe +0 -0
  44. magnax/public/scrcpy/scrcpy-win64-v2.4/swresample-4.dll +0 -0
  45. magnax/static/css/highlight.min.css +9 -0
  46. magnax/static/css/magnax-dark-theme.css +1237 -0
  47. magnax/static/css/select2-bootstrap-5-theme.min.css +3 -0
  48. magnax/static/css/select2-bootstrap-5-theme.rtl.min.css +3 -0
  49. magnax/static/css/select2.min.css +1 -0
  50. magnax/static/css/sweetalert2.min.css +1 -0
  51. magnax/static/css/tabler.demo.min.css +9 -0
  52. magnax/static/css/tabler.min.css +14 -0
  53. magnax/static/image/500.png +0 -0
  54. magnax/static/image/avatar.png +0 -0
  55. magnax/static/image/empty.png +0 -0
  56. magnax/static/image/readme/home.png +0 -0
  57. magnax/static/image/readme/pk.png +0 -0
  58. magnax/static/js/apexcharts.js +14 -0
  59. magnax/static/js/gray.js +16 -0
  60. magnax/static/js/highlight.min.js +1173 -0
  61. magnax/static/js/highstock.js +803 -0
  62. magnax/static/js/html2canvas.min.js +20 -0
  63. magnax/static/js/jquery.min.js +2 -0
  64. magnax/static/js/magnax-chart-theme.js +492 -0
  65. magnax/static/js/select2.min.js +2 -0
  66. magnax/static/js/sweetalert2.min.js +1 -0
  67. magnax/static/js/tabler.demo.min.js +9 -0
  68. magnax/static/js/tabler.min.js +9 -0
  69. magnax/static/logo/logo.png +0 -0
  70. magnax/templates/404.html +30 -0
  71. magnax/templates/analysis.html +1375 -0
  72. magnax/templates/analysis_compare.html +600 -0
  73. magnax/templates/analysis_pk.html +680 -0
  74. magnax/templates/base.html +365 -0
  75. magnax/templates/index.html +2471 -0
  76. magnax/templates/pk.html +743 -0
  77. magnax/templates/report.html +416 -0
  78. magnax/view/__init__.py +1 -0
  79. magnax/view/apis.py +952 -0
  80. magnax/view/pages.py +146 -0
  81. magnax/web.py +345 -0
  82. magnax-1.0.0.dist-info/METADATA +242 -0
  83. magnax-1.0.0.dist-info/RECORD +87 -0
  84. magnax-1.0.0.dist-info/WHEEL +5 -0
  85. magnax-1.0.0.dist-info/entry_points.txt +2 -0
  86. magnax-1.0.0.dist-info/licenses/LICENSE +21 -0
  87. magnax-1.0.0.dist-info/top_level.txt +1 -0
@@ -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
+