Skip to content

Commit

Permalink
fix #151
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa0128 committed May 17, 2023
1 parent 08a3d5f commit 4a2d231
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 74 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ We are committed to solving inefficient, cumbersome test execution, and our goal
- Install Python 3.10 + [**Download**](https://www.python.org/downloads/)
- Install adb and configure environment variables (SoloX's adb may not necessarily fit your computer) [**Download**](https://developer.android.com/studio/releases/platform-tools)

💡 Python 3.6 ~ 3.9 , please download a version of solox lower than 2.5.4.
💡 Python 3.6 ~ 3.9 , please download a version of solox lower than 2.5.4.

💡 If Windows users need to test ios, install and start Itunes. [**Documentation**](https://github.com/alibaba/taobao-iphone-device)

Expand All @@ -38,7 +38,7 @@ We are committed to solving inefficient, cumbersome test execution, and our goal
### default

```shell
pip install -U solox
pip install -U solox (pip install solox==2.6.2)
```

### mirrors
Expand Down Expand Up @@ -127,6 +127,8 @@ target in ['cpu','memory','network','fps','battery','gpu']
- 🌱2-devices: test the same app on two different phones.
- 🌱2-apps: test two different apps on two phones with the same configuration.

* **Collect in python/API:** Support Python and API to collect performance data, helping users easily integrate into automated testing processes.

## Browser

<img src="https://cdn.nlark.com/yuque/0/2023/png/153412/1677553244198-96ce5709-f33f-4038-888f-f330d1f74450.png" alt="Chrome" width="50px" height="50px" />
Expand Down
4 changes: 3 additions & 1 deletion README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ SoloX - Android/iOS性能数据的实时采集工具。
### 默认

```shell
pip install -U solox
pip install -U solox (指定版本:pip install solox==2.6.2)
```

### 镜像
Expand Down Expand Up @@ -131,6 +131,8 @@ target in ['cpu','memory','network','fps','battery','gpu']
- 🌱2-devices: 使用两台不同的设备测试同一个app。
- 🌱2-apps: 使用两台配置相同的设备测试两个不同的app。

* **API收集性能数据:** 支持python、API收集性能数据,帮助用户轻松集成在CI/CD流程。

## 浏览器

<img src="https://cdn.nlark.com/yuque/0/2023/png/153412/1677553244198-96ce5709-f33f-4038-888f-f330d1f74450.png" alt="Chrome" width="50px" height="50px" />
Expand Down
2 changes: 1 addition & 1 deletion solox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

from __future__ import absolute_import

__version__ = '2.6.2'
__version__ = '2.6.3'
6 changes: 1 addition & 5 deletions solox/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@

def checkPyVer():
versions = platform.python_version().split('.')
if int(versions[0]) < 3:
logger.error('python version must be 3.10+ ,your python version is {}'.format(platform.python_version()))
logger.info('https://github.com/smart-test-ti/SoloX/blob/master/README.md#requirements')
return False
elif int(versions[1]) < 10:
if int(versions[0]) < 3 or int(versions[1]) < 10:
logger.error('python version must be 3.10+ ,your python version is {}'.format(platform.python_version()))
logger.info('https://github.com/smart-test-ti/SoloX/blob/master/README.md#requirements')
return False
Expand Down
114 changes: 59 additions & 55 deletions solox/public/apm.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,60 @@ def collectGpu(self):
break
return result

def setPerfs(self):
match(self.platform):
case Platform.Android:
adb.shell(cmd='dumpsys battery reset', deviceId=self.deviceId)
_flow = Flow(self.pkgName, self.deviceId, self.platform, pid=self.pid)
data = _flow.setAndroidNet()
f.record_net('end', data[0], data[1])
scene = f.make_report(app=self.pkgName, devices=self.deviceId,
platform=self.platform, model='normal')
summary = f._setAndroidPerfs(scene)
summary_dict = {}
summary_dict['cpu_app'] = summary['cpuAppRate']
summary_dict['cpu_sys'] = summary['cpuSystemRate']
summary_dict['mem_total'] = summary['totalPassAvg']
summary_dict['mem_native'] = summary['nativePassAvg']
summary_dict['mem_dalvik'] = summary['dalvikPassAvg']
summary_dict['fps'] = summary['fps']
summary_dict['jank'] = summary['jank']
summary_dict['level'] = summary['batteryLevel']
summary_dict['tem'] = summary['batteryTeml']
summary_dict['net_send'] = summary['flow_send']
summary_dict['net_recv'] = summary['flow_recv']
summary_dict['cpu_charts'] = f.getCpuLog(Platform.Android, scene)
summary_dict['mem_charts'] = f.getMemLog(Platform.Android, scene)
summary_dict['net_charts'] = f.getFlowLog(Platform.Android, scene)
summary_dict['battery_charts'] = f.getBatteryLog(Platform.Android, scene)
summary_dict['fps_charts'] = f.getFpsLog(Platform.Android, scene)['fps']
summary_dict['jank_charts'] = f.getFpsLog(Platform.Android, scene)['jank']
f.make_android_html(scene=scene, summary=summary_dict)
case Platform.iOS:
scene = f.make_report(app=self.pkgName, devices=self.deviceId,
platform=self.platform, model='normal')
summary = f._setiOSPerfs(scene)
summary_dict = {}
summary_dict['cpu_app'] = summary['cpuAppRate']
summary_dict['cpu_sys'] = summary['cpuSystemRate']
summary_dict['mem_total'] = summary['totalPassAvg']
summary_dict['fps'] = summary['fps']
summary_dict['current'] = summary['batteryCurrent']
summary_dict['voltage'] = summary['batteryVoltage']
summary_dict['power'] = summary['batteryPower']
summary_dict['tem'] = summary['batteryTeml']
summary_dict['gpu'] = summary['gpu']
summary_dict['net_send'] = summary['flow_send']
summary_dict['net_recv'] = summary['flow_recv']
summary_dict['cpu_charts'] = f.getCpuLog(Platform.iOS, scene)
summary_dict['mem_charts'] = f.getMemLog(Platform.iOS, scene)
summary_dict['net_charts'] = f.getFlowLog(Platform.iOS, scene)
summary_dict['battery_charts'] = f.getBatteryLog(Platform.iOS, scene)
summary_dict['fps_charts'] = f.getFpsLog(Platform.iOS, scene)
summary_dict['gpu_charts'] = f.getGpuLog(Platform.iOS, scene)
f.make_ios_html(scene=scene, summary=summary_dict)
case _:
raise Exception('platfrom is invalid')

def collectAll(self):
try:
Expand All @@ -443,60 +497,10 @@ def collectAll(self):
pool.apply_async(self.collectGpu)
pool.close()
pool.join()
match(self.platform):
case Platform.Android:
adb.shell(cmd='dumpsys battery reset', deviceId=self.deviceId)
_flow = Flow(self.pkgName, self.deviceId, self.platform, pid=self.pid)
data = _flow.setAndroidNet()
f.record_net('end', data[0], data[1])
scene = f.make_report(app=self.pkgName, devices=self.deviceId,
platform=self.platform, model='normal')
summary = f._setAndroidPerfs(scene)
summary_dict = {}
summary_dict['cpu_app'] = summary['cpuAppRate']
summary_dict['cpu_sys'] = summary['cpuSystemRate']
summary_dict['mem_total'] = summary['totalPassAvg']
summary_dict['mem_native'] = summary['nativePassAvg']
summary_dict['mem_dalvik'] = summary['dalvikPassAvg']
summary_dict['fps'] = summary['fps']
summary_dict['jank'] = summary['jank']
summary_dict['level'] = summary['batteryLevel']
summary_dict['tem'] = summary['batteryTeml']
summary_dict['net_send'] = summary['flow_send']
summary_dict['net_recv'] = summary['flow_recv']
summary_dict['cpu_charts'] = f.getCpuLog(Platform.Android, scene)
summary_dict['mem_charts'] = f.getMemLog(Platform.Android, scene)
summary_dict['net_charts'] = f.getFlowLog(Platform.Android, scene)
summary_dict['battery_charts'] = f.getBatteryLog(Platform.Android, scene)
summary_dict['fps_charts'] = f.getFpsLog(Platform.Android, scene)['fps']
summary_dict['jank_charts'] = f.getFpsLog(Platform.Android, scene)['jank']
f.make_android_html(scene=scene, summary=summary_dict)
case Platform.iOS:
scene = f.make_report(app=self.pkgName, devices=self.deviceId,
platform=self.platform, model='normal')
summary = f._setiOSPerfs(scene)
summary_dict = {}
summary_dict['cpu_app'] = summary['cpuAppRate']
summary_dict['cpu_sys'] = summary['cpuSystemRate']
summary_dict['mem_total'] = summary['totalPassAvg']
summary_dict['fps'] = summary['fps']
summary_dict['current'] = summary['batteryCurrent']
summary_dict['voltage'] = summary['batteryVoltage']
summary_dict['power'] = summary['batteryPower']
summary_dict['tem'] = summary['batteryTeml']
summary_dict['gpu'] = summary['gpu']
summary_dict['net_send'] = summary['flow_send']
summary_dict['net_recv'] = summary['flow_recv']
summary_dict['cpu_charts'] = f.getCpuLog(Platform.iOS, scene)
summary_dict['mem_charts'] = f.getMemLog(Platform.iOS, scene)
summary_dict['net_charts'] = f.getFlowLog(Platform.iOS, scene)
summary_dict['battery_charts'] = f.getBatteryLog(Platform.iOS, scene)
summary_dict['fps_charts'] = f.getFpsLog(Platform.iOS, scene)
summary_dict['gpu_charts'] = f.getGpuLog(Platform.iOS, scene)
f.make_ios_html(scene=scene, summary=summary_dict)
case _:
raise Exception('platfrom is invalid')
self.setPerfs()
except KeyboardInterrupt:
logger.info('End of testing')
self.setPerfs()
except Exception:
traceback.print_exc()
traceback.print_exc()
finally:
logger.info('End of testing')
4 changes: 2 additions & 2 deletions solox/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ <h1 class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-m
{% if model in ['2-app','2-devices'] %}
<div class="nav-item dropdown d-none d-md-flex me-3">
<a href="/?platform=Android&lan={{ lan }}" class="btn btn-pill w-100" >
<svg t="1682331413507" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="9942" width="50" height="50"><path d="M512.149985 512.049995m-511.950005 0a511.950005 511.950005 0 1 0 1023.90001 0 511.950005 511.950005 0 1 0-1023.90001 0Z" fill="#1BAF96" p-id="9943"></path><path d="M634.738014 267.273899l-122.288058 265.974026L440.956938 734.92823l-125.087785 37.796309L286.971975 782.923543l-13.998633 23.997656 314.16932 211.579338c247.175862-36.296455 436.957328-249.175666 436.957328-506.450542 0-39.596133-4.499561-78.192364-12.99873-115.288741L740.927644 208.979592l-106.18963 58.294307z" fill="#199E85" p-id="9944"></path><path d="M650.03652 582.14315l-59.3942-56.894444c-13.998633-13.398692 0-27.197344 0-27.197344l63.79377-60.994043c43.295772-41.395957 41.495948-101.79006 41.495948-101.79006V256.974905l-183.382092-15.298506L329.167855 256.974905v78.292354s-1.799824 60.294112 41.495947 101.79006l63.793771 60.994043s13.998633 13.798652 0 27.197344L374.963382 582.14315s-45.795528 43.495752-45.795527 112.888976v77.692413h366.664193v-77.692413c0-69.393223-45.795528-112.888976-45.795528-112.888976z" fill="#FFFFFF" p-id="9945"></path><path d="M497.25144 679.83361l0.499951-168.083586c0.19998-31.496924-14.598574-51.394981-20.298017-57.094424L412.959672 392.961625c-21.897862-20.897959-22.697783-55.494581-22.697784-55.794551h244.476126s-0.399961 34.496631-22.697784 55.794551l-63.79377 60.994043c-6.499365 6.399375-20.797969 26.297432-20.597988 57.794356v168.083586h-30.397032z" fill="#4F5D73" p-id="9946"></path><path d="M757.026072 236.676887c0 16.89835-13.698662 30.597012-30.597012 30.597012H298.570843c-16.89835 0-30.597012-13.698662-30.597012-30.597012s13.698662-30.597012 30.597012-30.597012h427.758226c16.99834 0.09999 30.697002 13.798652 30.697003 30.597012z m0 550.046285c0 16.89835-13.698662 30.597012-30.597012 30.597012H298.570843c-16.89835 0-30.597012-13.698662-30.597012-30.597012 0-16.89835 13.698662-30.597012 30.597012-30.597012h427.758226c16.99834 0.09999 30.697002 13.798652 30.697003 30.597012z" fill="#F2B955" p-id="9947"></path><path d="M650.03652 756.22615H374.963382L512.549946 633.938092l137.486574 122.288058z" fill="#4F5D73" p-id="9948"></path></svg>
<svg t="1684145849174" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="12372" width="50" height="50"><path d="M512 64C264.576 64 64 264.576 64 512s200.576 448 448 448 448-200.576 448-448S759.424 64 512 64z" fill="#94BFFF" p-id="12373"></path><path d="M498.56 519.666a10.668 10.668 0 0 1 0-15.332c21.718-21.126 84.97-82.904 148.374-147.128 14.336-14.516 19.86-35.152 7.744-51.408-4.972-6.654-11.584-14.192-20.352-22.284-11.926-11.014-23.296-18.38-32.768-23.28-15.51-8.02-33.686-3.928-47.766 6.24-110.25 79.572-185.43 165.484-221.802 211.612-15.98 20.29-15.98 47.538 0 67.828 36.372 46.128 111.552 132.04 221.802 211.614 14.08 10.166 32.256 14.256 47.766 6.238 9.472-4.9 20.842-12.266 32.768-23.28 8.768-8.092 15.38-15.63 20.352-22.284 12.116-16.256 6.592-36.892-7.744-51.406-63.404-64.226-126.656-126.004-148.374-147.13z" fill="#1677FF" p-id="12374"></path></svg>
{% if lan == 'cn' %} 普通模式 {% else %} Normal Model {% endif %}
</a>
</div>
Expand Down Expand Up @@ -130,7 +130,7 @@ <h2 class="page-title">
</li>
<li class="list-inline-item">
<a href="https://github.com/smart-test-ti/SoloX/releases" target="_blank" class="link-secondary" rel="noopener">
{% if lan == 'cn' %} 版本 {% else %} Releases {% endif %} . V2.6.2
{% if lan == 'cn' %} 版本 {% else %} Releases {% endif %} . V2.6.3
</a>
</li>
</ul>
Expand Down
28 changes: 23 additions & 5 deletions solox/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
var timerQ = null;

function getCpuRate(pkgname,device){
var process = '';
if(platform == 'Android'){
process = $('.select-pid').val()
}
$.ajax({
url: Host + "/apm/cpu",
type: "GET",
Expand All @@ -482,7 +486,7 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
platform:platform,
pkgname:pkgname,
device:device,
process:$('.select-pid').val()
process:process
},
beforeSend: function () {
window.clearTimeout(timerQ);
Expand Down Expand Up @@ -605,6 +609,10 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
}

function getMemPss(pkgname,device) {
var process = '';
if(platform == 'Android'){
process = $('.select-pid').val()
}
$.ajax({
url: Host + "/apm/mem",
type: "GET",
Expand All @@ -615,7 +623,7 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
platform:platform,
pkgname:pkgname,
device:device,
process:$('.select-pid').val()
process:process
},
beforeSend: function () {
window.clearTimeout(timerQ);
Expand Down Expand Up @@ -658,6 +666,10 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
}

function setNetWork(type,device,pkgname,net_switch){
var process = '';
if(platform == 'Android'){
process = $('.select-pid').val()
}
$.ajax({
url: Host + "/apm/set/network",
type: "GET",
Expand All @@ -669,7 +681,7 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
device:device,
wifi_switch: net_switch,
type: type,
process:$('.select-pid').val()
process:process
},
success: function (data) {
if(data['status'] != 1){
Expand All @@ -684,6 +696,10 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
}

function getNetWork(pkgname,device,net_switch) {
var process = '';
if(platform == 'Android'){
process = $('.select-pid').val()
}
$.ajax({
url: Host + "/apm/network",
type: "GET",
Expand All @@ -695,7 +711,7 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
pkgname:pkgname,
device:device,
wifi_switch: net_switch,
process:$('.select-pid').val()
process:process
},
beforeSend: function () {
window.clearTimeout(timerQ);
Expand Down Expand Up @@ -1394,7 +1410,9 @@ <h2 class="offcanvas-title" id="offcanvasBottomLabel">Start-up Time</h2>
let pkgname = $('.select-app').val();
if(device && pkgname){
var net_switch = $('#net-switch').is(':checked');
setNetWork('pre',device,pkgname,net_switch)
if(platform == 'Android'){
setNetWork('pre',device,pkgname,net_switch)
}
collectCpu(device,pkgname);
collectMem(device,pkgname);
collectNetwork(device,pkgname);
Expand Down
Loading

0 comments on commit 4a2d231

Please sign in to comment.