magnax 1.0.0__tar.gz

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 (94) hide show
  1. magnax-1.0.0/LICENSE +21 -0
  2. magnax-1.0.0/MANIFEST.in +8 -0
  3. magnax-1.0.0/PKG-INFO +242 -0
  4. magnax-1.0.0/README.md +197 -0
  5. magnax-1.0.0/magnax/__init__.py +3 -0
  6. magnax-1.0.0/magnax/__main__.py +25 -0
  7. magnax-1.0.0/magnax/debug.py +65 -0
  8. magnax-1.0.0/magnax/public/__init__.py +1 -0
  9. magnax-1.0.0/magnax/public/adb/linux/adb +0 -0
  10. magnax-1.0.0/magnax/public/adb/linux_arm/adb +0 -0
  11. magnax-1.0.0/magnax/public/adb/mac/adb +0 -0
  12. magnax-1.0.0/magnax/public/adb/windows/AdbWinApi.dll +0 -0
  13. magnax-1.0.0/magnax/public/adb/windows/AdbWinUsbApi.dll +0 -0
  14. magnax-1.0.0/magnax/public/adb/windows/adb.exe +0 -0
  15. magnax-1.0.0/magnax/public/adb.py +96 -0
  16. magnax-1.0.0/magnax/public/android_fps.py +750 -0
  17. magnax-1.0.0/magnax/public/apm.py +1306 -0
  18. magnax-1.0.0/magnax/public/apm_pk.py +184 -0
  19. magnax-1.0.0/magnax/public/common.py +1598 -0
  20. magnax-1.0.0/magnax/public/config.json +1 -0
  21. magnax-1.0.0/magnax/public/ios_perf_adapter.py +790 -0
  22. magnax-1.0.0/magnax/public/report_template/android.html +526 -0
  23. magnax-1.0.0/magnax/public/report_template/ios.html +482 -0
  24. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinApi.dll +0 -0
  25. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/AdbWinUsbApi.dll +0 -0
  26. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/SDL2.dll +0 -0
  27. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/adb.exe +0 -0
  28. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/avcodec-60.dll +0 -0
  29. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/avformat-60.dll +0 -0
  30. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/avutil-58.dll +0 -0
  31. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/icon.png +0 -0
  32. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/libusb-1.0.dll +0 -0
  33. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/open_a_terminal_here.bat +1 -0
  34. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-console.bat +2 -0
  35. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-noconsole.vbs +7 -0
  36. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy-server +0 -0
  37. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/scrcpy.exe +0 -0
  38. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win32-v2.4/swresample-4.dll +0 -0
  39. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinApi.dll +0 -0
  40. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/AdbWinUsbApi.dll +0 -0
  41. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/SDL2.dll +0 -0
  42. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/avformat-60.dll +0 -0
  43. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/avutil-58.dll +0 -0
  44. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/open_a_terminal_here.bat +1 -0
  45. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-noconsole.vbs +7 -0
  46. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy-server +0 -0
  47. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/scrcpy.exe +0 -0
  48. magnax-1.0.0/magnax/public/scrcpy/scrcpy-win64-v2.4/swresample-4.dll +0 -0
  49. magnax-1.0.0/magnax/static/css/highlight.min.css +9 -0
  50. magnax-1.0.0/magnax/static/css/magnax-dark-theme.css +1237 -0
  51. magnax-1.0.0/magnax/static/css/select2-bootstrap-5-theme.min.css +3 -0
  52. magnax-1.0.0/magnax/static/css/select2-bootstrap-5-theme.rtl.min.css +3 -0
  53. magnax-1.0.0/magnax/static/css/select2.min.css +1 -0
  54. magnax-1.0.0/magnax/static/css/sweetalert2.min.css +1 -0
  55. magnax-1.0.0/magnax/static/css/tabler.demo.min.css +9 -0
  56. magnax-1.0.0/magnax/static/css/tabler.min.css +14 -0
  57. magnax-1.0.0/magnax/static/image/500.png +0 -0
  58. magnax-1.0.0/magnax/static/image/avatar.png +0 -0
  59. magnax-1.0.0/magnax/static/image/empty.png +0 -0
  60. magnax-1.0.0/magnax/static/image/readme/home.png +0 -0
  61. magnax-1.0.0/magnax/static/image/readme/pk.png +0 -0
  62. magnax-1.0.0/magnax/static/js/apexcharts.js +14 -0
  63. magnax-1.0.0/magnax/static/js/gray.js +16 -0
  64. magnax-1.0.0/magnax/static/js/highlight.min.js +1173 -0
  65. magnax-1.0.0/magnax/static/js/highstock.js +803 -0
  66. magnax-1.0.0/magnax/static/js/html2canvas.min.js +20 -0
  67. magnax-1.0.0/magnax/static/js/jquery.min.js +2 -0
  68. magnax-1.0.0/magnax/static/js/magnax-chart-theme.js +492 -0
  69. magnax-1.0.0/magnax/static/js/select2.min.js +2 -0
  70. magnax-1.0.0/magnax/static/js/sweetalert2.min.js +1 -0
  71. magnax-1.0.0/magnax/static/js/tabler.demo.min.js +9 -0
  72. magnax-1.0.0/magnax/static/js/tabler.min.js +9 -0
  73. magnax-1.0.0/magnax/static/logo/logo.png +0 -0
  74. magnax-1.0.0/magnax/templates/404.html +30 -0
  75. magnax-1.0.0/magnax/templates/analysis.html +1375 -0
  76. magnax-1.0.0/magnax/templates/analysis_compare.html +600 -0
  77. magnax-1.0.0/magnax/templates/analysis_pk.html +680 -0
  78. magnax-1.0.0/magnax/templates/base.html +365 -0
  79. magnax-1.0.0/magnax/templates/index.html +2471 -0
  80. magnax-1.0.0/magnax/templates/pk.html +743 -0
  81. magnax-1.0.0/magnax/templates/report.html +416 -0
  82. magnax-1.0.0/magnax/view/__init__.py +1 -0
  83. magnax-1.0.0/magnax/view/apis.py +952 -0
  84. magnax-1.0.0/magnax/view/pages.py +146 -0
  85. magnax-1.0.0/magnax/web.py +345 -0
  86. magnax-1.0.0/magnax.egg-info/PKG-INFO +242 -0
  87. magnax-1.0.0/magnax.egg-info/SOURCES.txt +93 -0
  88. magnax-1.0.0/magnax.egg-info/dependency_links.txt +1 -0
  89. magnax-1.0.0/magnax.egg-info/entry_points.txt +2 -0
  90. magnax-1.0.0/magnax.egg-info/requires.txt +11 -0
  91. magnax-1.0.0/magnax.egg-info/top_level.txt +1 -0
  92. magnax-1.0.0/pyproject.toml +70 -0
  93. magnax-1.0.0/setup.cfg +26 -0
  94. magnax-1.0.0/setup.py +70 -0
magnax-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 ~ now MagnaX . Rafa Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,8 @@
1
+ recursive-include magnax/public *.html *.js *.css *.png *.py *.json
2
+ recursive-include magnax/report *.html *.js *.css *.png *.py *.json *.log
3
+ recursive-include magnax/static *.html *.js *.css *.png *.py
4
+ recursive-include magnax/templates *.html *.js *.css *.png *.py
5
+ recursive-include magnax/view *.html *.js *.css *.png *.py
6
+ recursive-include magnax/public/adb *
7
+ recursive-include magnax/public/scrcpy *
8
+ recursive-include magnax/public/report_template *
magnax-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,242 @@
1
+ Metadata-Version: 2.4
2
+ Name: magnax
3
+ Version: 1.0.0
4
+ Summary: MagnaX - Real-time collection tool for Android/iOS performance data.
5
+ Home-page: https://github.com/smart-test-ti/MagnaX
6
+ Author: Rafa Chen
7
+ Author-email: Rafa Chen <rafacheninc@gmail.com>
8
+ License-Expression: MIT
9
+ Project-URL: Homepage, https://github.com/smart-test-ti/MagnaX
10
+ Project-URL: Repository, https://github.com/smart-test-ti/MagnaX
11
+ Project-URL: Documentation, https://github.com/smart-test-ti/MagnaX#readme
12
+ Project-URL: Issues, https://github.com/smart-test-ti/MagnaX/issues
13
+ Keywords: android,ios,performance,testing,monitoring,apm
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Environment :: Console
16
+ Classifier: Environment :: Web Environment
17
+ Classifier: Intended Audience :: Developers
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Programming Language :: Python :: 3
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Programming Language :: Python :: 3.13
24
+ Classifier: Programming Language :: Python :: 3.14
25
+ Classifier: Topic :: Software Development :: Testing
26
+ Classifier: Topic :: System :: Monitoring
27
+ Requires-Python: >=3.10
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+ Requires-Dist: flask>=3.1.0
31
+ Requires-Dist: requests>=2.28.2
32
+ Requires-Dist: loguru
33
+ Requires-Dist: fire
34
+ Requires-Dist: tqdm
35
+ Requires-Dist: openpyxl>=3.1.0
36
+ Requires-Dist: pyfiglet
37
+ Requires-Dist: psutil
38
+ Requires-Dist: opencv-python
39
+ Requires-Dist: pymobiledevice3>=2.0.0
40
+ Requires-Dist: py-ios-device>=2.0.0
41
+ Dynamic: author
42
+ Dynamic: home-page
43
+ Dynamic: license-file
44
+ Dynamic: requires-python
45
+
46
+ <p align="center">
47
+ <a>English</a> | <a href="./README.zh.md">中文</a> | <a href="./FAQ.md">FAQ</a> | <a href="https://mp.weixin.qq.com/s?__biz=MzkxMzYyNDM2NA==&mid=2247484506&idx=1&sn=b7eb6de68f84bed03001375d08e08ce9&chksm=c17b9819f60c110fd14e652c104237821b95a13da04618e98d2cf27afa798cb45e53cf50f5bd&token=1402046775&lang=zh_CN&poc_token=HKmRi2WjP7gf9CVwvLWQ2cRhrUR3wmbB9-fNZdD4" target="__blank">使用文档</a>
48
+ </p>
49
+
50
+ <p align="center">
51
+ <a href="#">
52
+ <img src="https://cdn.nlark.com/yuque/0/2024/png/153412/1715927541315-fb4f7662-d8bb-4d3e-a712-13a3c3073ac8.png?x-oss-process=image%2Fformat%2Cwebp" alt="MagnaX" width="100">
53
+ </a>
54
+ <br>
55
+ </p>
56
+ <p align="center">
57
+ <a href="https://pypi.org/project/magnax/" target="__blank"><img src="https://img.shields.io/pypi/v/magnax" alt="magnax preview"></a>
58
+ <a href="https://pepy.tech/project/magnax" target="__blank"><img src="https://static.pepy.tech/personalized-badge/magnax?period=total&units=international_system&left_color=grey&right_color=orange&left_text=downloads"></a>
59
+
60
+ <br>
61
+ </p>
62
+
63
+ ## 🔎Preview
64
+
65
+ MagnaX - Real-time collection tool for Android/iOS performance data.
66
+
67
+ Quickly locate and analyze performance issues to improve application performance and quality. No need for ROOT/jailbreak, plug and play.
68
+
69
+ ![10 161 9 178_50003__platform=Android lan=en (1)](https://github.com/smart-test-ti/MagnaX/assets/24454096/61a0b801-23b4-4711-8215-51cd7bc9dc04)
70
+
71
+ ## 📦Requirements
72
+
73
+ - Install Python 3.10 + (supports up to Python 3.14) [**Download**](https://www.python.org/downloads/)
74
+ - Install adb and configure environment variables (MagnaX's adb may not necessarily fit your computer) [**Download**](https://developer.android.com/studio/releases/platform-tools)
75
+
76
+ 💡 If Windows users need to test iOS, install and start iTunes. [**Documentation**](https://github.com/alibaba/taobao-iphone-device)
77
+
78
+ 💡 For iOS 17+ devices, you need to start the pymobiledevice3 tunnel service first:
79
+
80
+ ```shell
81
+ # macOS/Linux (requires sudo)
82
+ sudo python3 -m pymobiledevice3 remote start-tunnel
83
+
84
+ # Or run as a background daemon
85
+ sudo python3 -m pymobiledevice3 remote tunneld
86
+ ```
87
+
88
+ ## 📥Installation
89
+
90
+ ### default
91
+
92
+ ```shell
93
+ pip install -U magnax (pip install magnax==version)
94
+ ```
95
+
96
+ ### mirrors
97
+
98
+ ```shell
99
+ pip install -i https://mirrors.ustc.edu.cn/pypi/web/simple -U magnax
100
+ ```
101
+
102
+ 💡 If your network is unable to download through [pip install -U magnax], please try using mirrors to download, but the download of MagnaX may not be the latest version.
103
+
104
+ ## 🚀Quickstart
105
+
106
+ ### default
107
+
108
+ ```shell
109
+ python -m magnax
110
+ ```
111
+
112
+ ### customize
113
+
114
+ ```shell
115
+ python -m magnax --host=ip --port=port
116
+ ```
117
+
118
+ ## 🏴󠁣󠁩󠁣󠁭󠁿Python API
119
+
120
+ ```python
121
+ # magnax version : >= 2.8.5
122
+ from magnax.public.apm import AppPerformanceMonitor
123
+ from magnax.public.common import Devices
124
+
125
+ d = Devices()
126
+ processList = d.getPid(deviceId='ca6bd5a5', pkgName='com.bilibili.app.in') # for android
127
+ print(processList) # ['{pid}:{packagename}',...]
128
+
129
+ apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True,
130
+ noLog=False, pid=None, record=False, collect_all=False, duration=0)
131
+ # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS') only supports one device
132
+ # surfaceview: False = gfxinfo (Developer - GPU rendering mode - adb shell dumpsys gfxinfo)
133
+ # noLog : False (Save test data to log file)
134
+
135
+ # ************* Collect a performance parameter ************* #
136
+ cpu = apm.collectCpu() # %
137
+ memory = apm.collectMemory() # MB
138
+ memory_detail = apm.collectMemoryDetail() # MB
139
+ network = apm.collectNetwork(wifi=True) # KB
140
+ fps = apm.collectFps() # HZ
141
+ battery = apm.collectBattery() # level:% temperature:°C current:mA voltage:mV power:w
142
+ gpu = apm.collectGpu() # %
143
+ disk = apm.collectDisk()
144
+ thermal = apm.collectThermal()
145
+ # ************* Collect all performance parameter ************* #
146
+
147
+ if __name__ == '__main__':
148
+ apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True,
149
+ noLog=False, pid=None, record=False, collect_all=True, duration=0)
150
+ # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS', deviceId='xxxx', noLog=False, record=False, collect_all=True, duration=0)
151
+ #duration: running time (second)
152
+ #record: record android screen
153
+ apm.collectAll(report_path=None) # report_path='/test/report.html'
154
+
155
+ # in other python file
156
+ from magnax.public.apm import initPerformanceService
157
+
158
+ initPerformanceService.stop() # stop magnax
159
+ ```
160
+
161
+ ## 🏴󠁣󠁩󠁣󠁭󠁿Service API
162
+
163
+ ### Start the service in the background
164
+
165
+ ```
166
+ # magnax version >= 2.1.5
167
+
168
+ macOS/Linux: nohup python3 -m magnax &
169
+ Windows: start /min python3 -m magnax &
170
+ ```
171
+
172
+ ### Request performance data from api
173
+
174
+ ```shell
175
+ Android: http://{ip}:{port}/apm/collect?platform=Android&deviceid=ca6bd5a5&pkgname=com.bilibili.app.in&target=cpu
176
+ iOS: http://{ip}:{port}/apm/collect?platform=iOS&pkgname=com.bilibili.app.in&target=cpu
177
+
178
+ target in ['cpu','memory','memory_detail','network','fps','battery','gpu']
179
+ ```
180
+
181
+ ## 🔥Features
182
+
183
+ * **No ROOT/Jailbreak:** No need of Root for Android devices, Jailbreak for iOS devices. Efficiently solving the test and analysis challenges in Android & iOS performance.
184
+ * **Data Integrality:** We provide the data about CPU, GPU, Memory, Battery, Network,FPS, Jank, etc., which you may easy to get.
185
+ * **Beautiful Report:** A beautiful and detailed report analysis, where to store, visualize, edit, manage, and download all the test cases collected with MagnaX no matter where you are or when is it.
186
+ * **Useful Monitoring Settings:** Support setting alarm values, collecting duration, and accessing mobile devices on other PC machines during the monitoring process.
187
+ * **PK Model:** Supports simultaneous comparative testing of two mobile devices.
188
+
189
+ - 🌱2-devices: test the same app on two different phones.
190
+ - 🌱2-apps: test two different apps on two phones with the same configuration.
191
+ * **Collect In Python/API:** Support Python and API to collect performance data, helping users easily integrate into automated testing processes.
192
+
193
+ ## Develop
194
+
195
+ * https://github.com/pallets/flask
196
+ * https://github.com/tabler/tabler
197
+
198
+ ### Dependencies
199
+
200
+ | Package | Purpose |
201
+ |---|---|
202
+ | flask >= 3.1.0 | Web framework |
203
+ | loguru | Logging |
204
+ | openpyxl >= 3.1.0 | Excel report export (.xlsx) |
205
+ | pymobiledevice3 >= 2.0.0 | iOS device control |
206
+ | py-ios-device >= 2.0.0 | iOS performance data collection |
207
+ | fire | CLI argument parsing |
208
+ | psutil | System process utilities |
209
+ | opencv-python | Screen recording |
210
+
211
+ ### Debug
212
+
213
+ * Remove `magnax.` prefix in import paths
214
+
215
+ ```python
216
+ # example
217
+ from magnax.view.apis import api
218
+ # change to
219
+ from view.apis import api
220
+ ```
221
+
222
+ * Run debug server
223
+
224
+ ```shell
225
+ cd magnax
226
+ python debug.py
227
+ ```
228
+
229
+ ## Browser
230
+
231
+ <img src="https://cdn.nlark.com/yuque/0/2023/png/153412/1677553244198-96ce5709-f33f-4038-888f-f330d1f74450.png" alt="Chrome" width="50px" height="50px" />
232
+
233
+ ## Terminal
234
+
235
+ - windows: PowerShell
236
+ - macOS:iTerm2 (https://iterm2.com/)
237
+
238
+ ## 💕Thanks
239
+
240
+ - https://github.com/doronz88/pymobiledevice3
241
+ - https://github.com/YueChen-C/py-ios-device
242
+ - https://github.com/Genymobile/scrcpy
magnax-1.0.0/README.md ADDED
@@ -0,0 +1,197 @@
1
+ <p align="center">
2
+ <a>English</a> | <a href="./README.zh.md">中文</a> | <a href="./FAQ.md">FAQ</a> | <a href="https://mp.weixin.qq.com/s?__biz=MzkxMzYyNDM2NA==&mid=2247484506&idx=1&sn=b7eb6de68f84bed03001375d08e08ce9&chksm=c17b9819f60c110fd14e652c104237821b95a13da04618e98d2cf27afa798cb45e53cf50f5bd&token=1402046775&lang=zh_CN&poc_token=HKmRi2WjP7gf9CVwvLWQ2cRhrUR3wmbB9-fNZdD4" target="__blank">使用文档</a>
3
+ </p>
4
+
5
+ <p align="center">
6
+ <a href="#">
7
+ <img src="https://cdn.nlark.com/yuque/0/2024/png/153412/1715927541315-fb4f7662-d8bb-4d3e-a712-13a3c3073ac8.png?x-oss-process=image%2Fformat%2Cwebp" alt="MagnaX" width="100">
8
+ </a>
9
+ <br>
10
+ </p>
11
+ <p align="center">
12
+ <a href="https://pypi.org/project/magnax/" target="__blank"><img src="https://img.shields.io/pypi/v/magnax" alt="magnax preview"></a>
13
+ <a href="https://pepy.tech/project/magnax" target="__blank"><img src="https://static.pepy.tech/personalized-badge/magnax?period=total&units=international_system&left_color=grey&right_color=orange&left_text=downloads"></a>
14
+
15
+ <br>
16
+ </p>
17
+
18
+ ## 🔎Preview
19
+
20
+ MagnaX - Real-time collection tool for Android/iOS performance data.
21
+
22
+ Quickly locate and analyze performance issues to improve application performance and quality. No need for ROOT/jailbreak, plug and play.
23
+
24
+ ![10 161 9 178_50003__platform=Android lan=en (1)](https://github.com/smart-test-ti/MagnaX/assets/24454096/61a0b801-23b4-4711-8215-51cd7bc9dc04)
25
+
26
+ ## 📦Requirements
27
+
28
+ - Install Python 3.10 + (supports up to Python 3.14) [**Download**](https://www.python.org/downloads/)
29
+ - Install adb and configure environment variables (MagnaX's adb may not necessarily fit your computer) [**Download**](https://developer.android.com/studio/releases/platform-tools)
30
+
31
+ 💡 If Windows users need to test iOS, install and start iTunes. [**Documentation**](https://github.com/alibaba/taobao-iphone-device)
32
+
33
+ 💡 For iOS 17+ devices, you need to start the pymobiledevice3 tunnel service first:
34
+
35
+ ```shell
36
+ # macOS/Linux (requires sudo)
37
+ sudo python3 -m pymobiledevice3 remote start-tunnel
38
+
39
+ # Or run as a background daemon
40
+ sudo python3 -m pymobiledevice3 remote tunneld
41
+ ```
42
+
43
+ ## 📥Installation
44
+
45
+ ### default
46
+
47
+ ```shell
48
+ pip install -U magnax (pip install magnax==version)
49
+ ```
50
+
51
+ ### mirrors
52
+
53
+ ```shell
54
+ pip install -i https://mirrors.ustc.edu.cn/pypi/web/simple -U magnax
55
+ ```
56
+
57
+ 💡 If your network is unable to download through [pip install -U magnax], please try using mirrors to download, but the download of MagnaX may not be the latest version.
58
+
59
+ ## 🚀Quickstart
60
+
61
+ ### default
62
+
63
+ ```shell
64
+ python -m magnax
65
+ ```
66
+
67
+ ### customize
68
+
69
+ ```shell
70
+ python -m magnax --host=ip --port=port
71
+ ```
72
+
73
+ ## 🏴󠁣󠁩󠁣󠁭󠁿Python API
74
+
75
+ ```python
76
+ # magnax version : >= 2.8.5
77
+ from magnax.public.apm import AppPerformanceMonitor
78
+ from magnax.public.common import Devices
79
+
80
+ d = Devices()
81
+ processList = d.getPid(deviceId='ca6bd5a5', pkgName='com.bilibili.app.in') # for android
82
+ print(processList) # ['{pid}:{packagename}',...]
83
+
84
+ apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True,
85
+ noLog=False, pid=None, record=False, collect_all=False, duration=0)
86
+ # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS') only supports one device
87
+ # surfaceview: False = gfxinfo (Developer - GPU rendering mode - adb shell dumpsys gfxinfo)
88
+ # noLog : False (Save test data to log file)
89
+
90
+ # ************* Collect a performance parameter ************* #
91
+ cpu = apm.collectCpu() # %
92
+ memory = apm.collectMemory() # MB
93
+ memory_detail = apm.collectMemoryDetail() # MB
94
+ network = apm.collectNetwork(wifi=True) # KB
95
+ fps = apm.collectFps() # HZ
96
+ battery = apm.collectBattery() # level:% temperature:°C current:mA voltage:mV power:w
97
+ gpu = apm.collectGpu() # %
98
+ disk = apm.collectDisk()
99
+ thermal = apm.collectThermal()
100
+ # ************* Collect all performance parameter ************* #
101
+
102
+ if __name__ == '__main__':
103
+ apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True,
104
+ noLog=False, pid=None, record=False, collect_all=True, duration=0)
105
+ # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS', deviceId='xxxx', noLog=False, record=False, collect_all=True, duration=0)
106
+ #duration: running time (second)
107
+ #record: record android screen
108
+ apm.collectAll(report_path=None) # report_path='/test/report.html'
109
+
110
+ # in other python file
111
+ from magnax.public.apm import initPerformanceService
112
+
113
+ initPerformanceService.stop() # stop magnax
114
+ ```
115
+
116
+ ## 🏴󠁣󠁩󠁣󠁭󠁿Service API
117
+
118
+ ### Start the service in the background
119
+
120
+ ```
121
+ # magnax version >= 2.1.5
122
+
123
+ macOS/Linux: nohup python3 -m magnax &
124
+ Windows: start /min python3 -m magnax &
125
+ ```
126
+
127
+ ### Request performance data from api
128
+
129
+ ```shell
130
+ Android: http://{ip}:{port}/apm/collect?platform=Android&deviceid=ca6bd5a5&pkgname=com.bilibili.app.in&target=cpu
131
+ iOS: http://{ip}:{port}/apm/collect?platform=iOS&pkgname=com.bilibili.app.in&target=cpu
132
+
133
+ target in ['cpu','memory','memory_detail','network','fps','battery','gpu']
134
+ ```
135
+
136
+ ## 🔥Features
137
+
138
+ * **No ROOT/Jailbreak:** No need of Root for Android devices, Jailbreak for iOS devices. Efficiently solving the test and analysis challenges in Android & iOS performance.
139
+ * **Data Integrality:** We provide the data about CPU, GPU, Memory, Battery, Network,FPS, Jank, etc., which you may easy to get.
140
+ * **Beautiful Report:** A beautiful and detailed report analysis, where to store, visualize, edit, manage, and download all the test cases collected with MagnaX no matter where you are or when is it.
141
+ * **Useful Monitoring Settings:** Support setting alarm values, collecting duration, and accessing mobile devices on other PC machines during the monitoring process.
142
+ * **PK Model:** Supports simultaneous comparative testing of two mobile devices.
143
+
144
+ - 🌱2-devices: test the same app on two different phones.
145
+ - 🌱2-apps: test two different apps on two phones with the same configuration.
146
+ * **Collect In Python/API:** Support Python and API to collect performance data, helping users easily integrate into automated testing processes.
147
+
148
+ ## Develop
149
+
150
+ * https://github.com/pallets/flask
151
+ * https://github.com/tabler/tabler
152
+
153
+ ### Dependencies
154
+
155
+ | Package | Purpose |
156
+ |---|---|
157
+ | flask >= 3.1.0 | Web framework |
158
+ | loguru | Logging |
159
+ | openpyxl >= 3.1.0 | Excel report export (.xlsx) |
160
+ | pymobiledevice3 >= 2.0.0 | iOS device control |
161
+ | py-ios-device >= 2.0.0 | iOS performance data collection |
162
+ | fire | CLI argument parsing |
163
+ | psutil | System process utilities |
164
+ | opencv-python | Screen recording |
165
+
166
+ ### Debug
167
+
168
+ * Remove `magnax.` prefix in import paths
169
+
170
+ ```python
171
+ # example
172
+ from magnax.view.apis import api
173
+ # change to
174
+ from view.apis import api
175
+ ```
176
+
177
+ * Run debug server
178
+
179
+ ```shell
180
+ cd magnax
181
+ python debug.py
182
+ ```
183
+
184
+ ## Browser
185
+
186
+ <img src="https://cdn.nlark.com/yuque/0/2023/png/153412/1677553244198-96ce5709-f33f-4038-888f-f330d1f74450.png" alt="Chrome" width="50px" height="50px" />
187
+
188
+ ## Terminal
189
+
190
+ - windows: PowerShell
191
+ - macOS:iTerm2 (https://iterm2.com/)
192
+
193
+ ## 💕Thanks
194
+
195
+ - https://github.com/doronz88/pymobiledevice3
196
+ - https://github.com/YueChen-C/py-ios-device
197
+ - https://github.com/Genymobile/scrcpy
@@ -0,0 +1,3 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ __version__ = '1.0.0'
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ """
4
+ MagnaX - Real-time performance monitoring tool for Android/iOS apps.
5
+
6
+ Usage:
7
+ magnax [--host=HOST] [--port=PORT]
8
+ python -m magnax [--host=HOST] [--port=PORT]
9
+
10
+ Examples:
11
+ magnax # Start with default settings (localhost:50003)
12
+ magnax --host=0.0.0.0 --port=8080 # Custom host and port
13
+ """
14
+
15
+ import fire
16
+ from magnax.web import main as web_main
17
+
18
+
19
+ def main():
20
+ """Entry point for the magnax command."""
21
+ fire.Fire(web_main)
22
+
23
+
24
+ if __name__ == '__main__':
25
+ main()
@@ -0,0 +1,65 @@
1
+ import multiprocessing
2
+ import subprocess
3
+ import time
4
+ import os
5
+ import webbrowser
6
+ import requests
7
+ import socket
8
+ import psutil
9
+ import sys
10
+ from view.apis import api
11
+ from view.pages import page
12
+ from loguru import logger
13
+ from flask import Flask
14
+ from pyfiglet import Figlet
15
+ from magnax import __version__
16
+
17
+ app = Flask(__name__, template_folder='templates', static_folder='static')
18
+ app.register_blueprint(api)
19
+ app.register_blueprint(page)
20
+
21
+
22
+ def ip() -> str:
23
+ try:
24
+ ip = socket.gethostbyname(socket.gethostname())
25
+ except:
26
+ ip = '127.0.0.1'
27
+ return ip
28
+
29
+ def listen(port):
30
+ net_connections = psutil.net_connections()
31
+ conn = [c for c in net_connections if c.status == "LISTEN" and c.laddr.port == port]
32
+ if conn:
33
+ pid = conn[0].pid
34
+ logger.warning('Port {} is used by process {}'.format(port, pid))
35
+ logger.info('you can start magnax : python -m magnax --host={ip} --port={port}')
36
+ return False
37
+ return True
38
+
39
+ def status(host: str, port: int):
40
+ r = requests.get('http://{}:{}'.format(host, port), timeout=2.0)
41
+ flag = (True, False)[r.status_code == 200]
42
+ return flag
43
+
44
+
45
+ def open_url(host: str, port: int):
46
+ flag = True
47
+ while flag:
48
+ logger.info('start magnax server ...')
49
+ f = Figlet(font="slant", width=300)
50
+ print(f.renderText("MAGNAX {}".format(__version__)))
51
+ flag = status(host, port)
52
+ webbrowser.open('http://{}:{}/?platform=Android&lan=en'.format(host, port), new=2)
53
+ logger.info('Running on http://{}:{}/?platform=Android&lan=en (Press CTRL+C to quit)'.format(host, port))
54
+
55
+
56
+ def start(host: str, port: int):
57
+ logger.info('Running on http://{}:{}/?platform=Android&lan=en (Press CTRL+C to quit)'.format(host, port))
58
+ app.run(host=host, port=port, debug=True)
59
+
60
+ def main(host=ip(), port=50003):
61
+ start(host, port)
62
+
63
+
64
+ if __name__ == '__main__':
65
+ main()
@@ -0,0 +1 @@
1
+
File without changes
File without changes
Binary file
File without changes
File without changes
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/python
2
+ # encoding=utf-8
3
+
4
+ """
5
+ @Author : Lijiawei
6
+ @Date : 2022/6/19
7
+ @Desc : adb line.
8
+ @Update : 2022/7/14 by Rafa chen
9
+ """
10
+ import os
11
+ import platform
12
+ import stat
13
+ import subprocess
14
+
15
+ STATICPATH = os.path.dirname(os.path.realpath(__file__))
16
+ DEFAULT_ADB_PATH = {
17
+ "Windows": os.path.join(STATICPATH, "adb", "windows", "adb.exe"),
18
+ "Darwin": os.path.join(STATICPATH, "adb", "mac", "adb"),
19
+ "Linux": os.path.join(STATICPATH, "adb", "linux", "adb"),
20
+ "Linux-x86_64": os.path.join(STATICPATH, "adb", "linux", "adb"),
21
+ "Linux-armv7l": os.path.join(STATICPATH, "adb", "linux_arm", "adb"),
22
+ }
23
+
24
+
25
+ def make_file_executable(file_path):
26
+ """
27
+ If the path does not have executable permissions, execute chmod +x
28
+ :param file_path:
29
+ :return:
30
+ """
31
+ if os.path.isfile(file_path):
32
+ mode = os.lstat(file_path)[stat.ST_MODE]
33
+ executable = True if mode & stat.S_IXUSR else False
34
+ if not executable:
35
+ os.chmod(file_path, mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
36
+ return True
37
+ return False
38
+
39
+
40
+ def builtin_adb_path():
41
+ """
42
+ Return built-in adb executable path
43
+
44
+ Returns:
45
+ adb executable path
46
+
47
+ """
48
+ system = platform.system()
49
+ machine = platform.machine()
50
+ adb_path = DEFAULT_ADB_PATH.get('{}-{}'.format(system, machine))
51
+ proc = subprocess.Popen('adb devices', stdout=subprocess.PIPE, shell=True)
52
+ result = proc.stdout.read()
53
+ if not isinstance(result, str):
54
+ result = str(result, 'utf-8')
55
+ if result and "command not found" not in result:
56
+ adb_path = "adb"
57
+ return adb_path
58
+
59
+ if not adb_path:
60
+ adb_path = DEFAULT_ADB_PATH.get(system)
61
+ if not adb_path:
62
+ raise RuntimeError("No adb executable supports this platform({}-{}).".format(system, machine))
63
+
64
+ # overwrite uiautomator adb
65
+ if "ANDROID_HOME" in os.environ:
66
+ del os.environ["ANDROID_HOME"]
67
+ if system != "Windows":
68
+ # chmod +x adb
69
+ make_file_executable(adb_path)
70
+ return adb_path
71
+
72
+
73
+ class ADB(object):
74
+
75
+ def __init__(self):
76
+ self.adb_path = builtin_adb_path()
77
+
78
+ def shell(self, cmd, deviceId):
79
+ run_cmd = f'{self.adb_path} -s {deviceId} shell {cmd}'
80
+ result = subprocess.Popen(run_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()[
81
+ 0].decode("utf-8").strip()
82
+ return result
83
+
84
+ def tcp_shell(self, deviceId, cmd):
85
+ run_cmd = f'{self.adb_path} -s {deviceId} {cmd}'
86
+ result = os.system(run_cmd)
87
+ return result
88
+
89
+ def shell_noDevice(self, cmd):
90
+ run_cmd = f'{self.adb_path} {cmd}'
91
+ result = os.system(run_cmd)
92
+ return result
93
+
94
+
95
+
96
+ adb = ADB()