Skip to content

Commit

Permalink
fixed bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
rafa0128 committed Apr 21, 2023
1 parent 40b3f67 commit 25df147
Show file tree
Hide file tree
Showing 14 changed files with 1,209 additions and 56 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ recursive-include solox/static *.html *.js *.css *.png *.py
recursive-include solox/templates *.html *.js *.css *.png *.py
recursive-include solox/view *.html *.js *.css *.png *.py
recursive-include solox/public/adb *
recursive-include solox/public/report_template *
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<br>
</p>

## 🔎Preview
## 🔎Preview

SoloX - Real-time collection tool for Android/iOS performance data.

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

## 📦Requirements

- Install Python 3.10 + [**Download**](https://www.python.org/downloads/)
Install Python 3.10 + [**Download**](https://www.python.org/downloads/)

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

Expand Down Expand Up @@ -65,6 +65,7 @@ python -m solox --host={ip} --port={port}
## 🏴󠁣󠁩󠁣󠁭󠁿Collect in python

```python

from solox.public.apm import APM
from solox.public.common import Devices

Expand All @@ -73,7 +74,8 @@ from solox.public.common import Devices
d = Devices()
pids = d.getPid(deviceId='ca6bd5a5', pkgName='com.bilibili.app.in')

apm = APM(pkgName='com.bilibili.app.in',deviceId='ca6bd5a5',platform='Android', surfaceview=True, noLog=True, pid=None)
apm = APM(pkgName='com.bilibili.app.in',deviceId='ca6bd5a5',platform='Android',
surfaceview=True, noLog=True, pid=None)
# apm = APM(pkgName='com.bilibili.app.in', platform='iOS') only supports one device
# surfaceview: False = gfxinfo (Developer - GPU rendering mode - adb shell dumpsys gfxinfo)
# noLog : False (Save test data to log file)
Expand Down Expand Up @@ -110,11 +112,11 @@ target in ['cpu','memory','network','fps','battery','gpu']

* **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.
* **Data Integrality:** We provide the data about Screenshot, CPU, GPU, Memory, Battery, Network,FPS, Jank, etc., which you may easy to get.
* **Beautiful report board:** A beautiful and detailed report analysis, where to store, visualize, edit, manage, and download all the test cases collected with SoloX no matter where you are or when is it.
* **Useful monitoring settings:** Support setting alarm values, collecting duration, and accessing mobile devices on other PC machines during the monitoring process.
* **PK model:** Supports simultaneous comparative testing of two mobile devices.
🌱2-devices: test the same app on two different phones.
🌱2-apps: test two different apps on two phones with the same configuration.
* **Beautiful Report:** A beautiful and detailed report analysis, where to store, visualize, edit, manage, and download all the test cases collected with SoloX no matter where you are or when is it.
* **Useful Monitoring Settings:** Support setting alarm values, collecting duration, and accessing mobile devices on other PC machines during the monitoring process.
* **PK Model:** Supports simultaneous comparative testing of two mobile devices.
- 🌱2-devices: test the same app on two different phones.
- 🌱2-apps: test two different apps on two phones with the same configuration.

## Browser

Expand Down
9 changes: 5 additions & 4 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SoloX - Android/iOS性能数据的实时采集工具。

## 📦环境

- 安装 Python 3.10 + [**Download**](https://www.python.org/downloads/)
安装 Python 3.10 + [**Download**](https://www.python.org/downloads/)

💡 Python 3.6 ~ 3.9 , 请安装solox版本低于2.5.4.

Expand Down Expand Up @@ -73,7 +73,8 @@ from solox.public.common import Devices
d = Devices()
pids = d.getPid(deviceId='ca6bd5a5', pkgName='com.bilibili.app.in')

apm = APM(pkgName='com.bilibili.app.in',deviceId='ca6bd5a5',platform='Android', surfaceview=True, noLog=True, pid=None)
apm = APM(pkgName='com.bilibili.app.in',deviceId='ca6bd5a5',platform='Android',
surfaceview=True, noLog=True, pid=None)
# apm = APM(pkgName='com.bilibili.app.in', platform='iOS') only supports one device
# surfaceview: False = gfxinfo (Developer - GPU rendering mode - adb shell dumpsys gfxinfo)
# noLog : False (Save test data to log file)
Expand Down Expand Up @@ -116,8 +117,8 @@ target in ['cpu','memory','network','fps','battery','gpu']
* **好用的监控设置:** 支持在监控过程中设置告警值、收集时长、访问其他PC机器的移动设备。

* **比对模式:** 支持两台移动设备同时对比测试。
🌱2-devices: 使用两台不同的设备测试同一个app。
🌱2-apps: 使用两台配置相同的设备测试两个不同的app。
- 🌱2-devices: 使用两台不同的设备测试同一个app。
- 🌱2-apps: 使用两台配置相同的设备测试两个不同的app。

## 浏览器

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.5.9'
__version__ = '2.6.0'
9 changes: 2 additions & 7 deletions solox/public/apm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import solox.public._iosPerf as iosP
from solox.public.iosperf._perf import DataType, Performance
from solox.public.adb import adb
from solox.public.common import Devices, file, Method, Platform
from solox.public.common import Devices, File, Method, Platform
from solox.public.fps import FPSMonitor, TimeUtils

d = Devices()
f = file()
f = File()
m = Method()

class Target:
Expand Down Expand Up @@ -106,7 +106,6 @@ def getCpuRate(self, noLog=False):
appCpuRate, systemCpuRate = self.getAndroidCpuRate(noLog) if self.platform == Platform.Android else self.getiOSCpuRate(noLog)
return appCpuRate, systemCpuRate


class MEM(object):
def __init__(self, pkgName, deviceId, platform=Platform.Android, pid=None):
self.pkgName = pkgName
Expand Down Expand Up @@ -148,7 +147,6 @@ def getProcessMem(self, noLog=False):
f.add_log(os.path.join(f.report_dir,'mem_dalvik.log'), apm_time, dalvikPass)
return totalPass, nativePass, dalvikPass


class Battery(object):
def __init__(self, deviceId, platform=Platform.Android):
self.deviceId = deviceId
Expand Down Expand Up @@ -201,7 +199,6 @@ def recoverBattery(self):
cmd = 'dumpsys battery reset'
adb.shell(cmd=cmd, deviceId=self.deviceId)


class Flow(object):

def __init__(self, pkgName, deviceId, platform=Platform.Android, pid=None):
Expand Down Expand Up @@ -256,7 +253,6 @@ def getNetWorkData(self, wifi=True, noLog=False):
f.add_log(os.path.join(f.report_dir,'downflow.log'), apm_time, recNum)
return sendNum, recNum


class FPS(object):

def __init__(self, pkgName, deviceId, platform=Platform.Android, surfaceview=True):
Expand Down Expand Up @@ -340,7 +336,6 @@ def getPerformance(self, perfTpe: DataType):
perf_value = perf.start(self.pkgName, callback=self.callback)
return perf_value


class APM(object):
"""for python api"""

Expand Down
4 changes: 2 additions & 2 deletions solox/public/apm_pk.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
import re
import time
from solox.public.adb import adb
from solox.public.common import Devices, file
from solox.public.common import Devices, File
from solox.public.fps import FPSMonitor, TimeUtils

d = Devices()
f = file()
f = File()


class CPU_PK:
Expand Down
76 changes: 60 additions & 16 deletions solox/public/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
from urllib.request import urlopen
import ssl
import xlwt

from jinja2 import Environment, FileSystemLoader

class Platform:
Android = 'Android'
iOS = 'iOS'
Expand Down Expand Up @@ -55,11 +56,8 @@ def getDevicesName(self, deviceId):

def getDevices(self):
"""Get all Android devices"""
Devices = []
DeviceIds = self.getDeviceIds()
for id in DeviceIds:
devices_name = self.getDevicesName(id)
Devices.append(f'{id}({devices_name})')
Devices = [f'{id}({self.getDevicesName(id)})' for id in DeviceIds]
return Devices

def getIdbyDevice(self, deviceinfo, platform):
Expand All @@ -76,12 +74,12 @@ def getPid(self, deviceId, pkgName):
"""Get the pid corresponding to the Android package name"""
result = os.popen(f"{self.adb} -s {deviceId} shell ps -ef | {self.filterType()} {pkgName}").readlines()
try:
processList = []
for process in result:
processInfo = '{}:{}'.format(process.split()[1],process.split()[7])
processList.append(processInfo)
processList = ['{}:{}'.format(process.split()[1],process.split()[7]) for process in result]
processList.reverse()
if len(processList) == 0:
logger.warning('no pid found')
except Exception:
logger.error('no pid found')
traceback.print_exc()
return processList

def checkPkgname(self, pkgname):
Expand Down Expand Up @@ -115,9 +113,7 @@ def getDeviceInfoByiOS(self):
def getPkgnameByiOS(self, udid):
"""Get all package names of the corresponding iOS device"""
pkgResult = self.execCmd(f'tidevice --udid {udid} applist').split('\n')
pkgNames = []
for i in range(len(pkgResult)):
pkgNames.append(pkgResult[i].split(' ')[0])
pkgNames = [pkgResult[i].split(' ')[0] for i in range(len(pkgResult))]
return pkgNames

def devicesCheck(self, platform, deviceid=None, pkgname=None):
Expand Down Expand Up @@ -155,14 +151,14 @@ def getDdeviceDetail(self, deviceId, platform):
raise Exception('{} is undefined'.format(platform))
return result

class file:
class File:

def __init__(self, fileroot='.'):
self.fileroot = fileroot
self.report_dir = self.get_repordir()

def export_excel(self, platform, scene):

logger.info('Exporting excel ...')
android_log_file_list = ['cpu_app','cpu_sys','mem_total','mem_native','mem_dalvik',
'battery_level', 'battery_tem','upflow','downflow','fps']
ios_log_file_list = ['cpu_app','cpu_sys', 'mem_total', 'battery_tem', 'battery_current',
Expand All @@ -187,7 +183,53 @@ def export_excel(self, platform, scene):
col += 1
row += 1
col = 0
wb.save(f'{scene}.xls')
xls_path = os.path.join(self.report_dir, scene, f'{scene}.xls')
wb.save(xls_path)
logger.info('Exporting excel success : {}'.format(xls_path))
return xls_path

def make_android_html(self, scene, summary : dict):
logger.info('Generating HTML ...')
STATICPATH = os.path.dirname(os.path.realpath(__file__))
file_loader = FileSystemLoader(os.path.join(STATICPATH, 'report_template'))
env = Environment(loader=file_loader)
template = env.get_template('android.html')
with open(os.path.join(self.report_dir, scene, 'report.html'),'w+') as fout:
html_content = template.render(cpu_app=summary['cpu_app'],cpu_sys=summary['cpu_sys'],
mem_total=summary['mem_total'],mem_native=summary['mem_native'],
mem_dalvik=summary['mem_dalvik'],fps=summary['fps'],
jank=summary['jank'],level=summary['level'],
tem=summary['tem'],net_send=summary['net_send'],
net_recv=summary['net_recv'],cpu_charts=summary['cpu_charts'],
mem_charts=summary['mem_charts'],net_charts=summary['net_charts'],
battery_charts=summary['battery_charts'],fps_charts=summary['fps_charts'],
jank_charts=summary['jank_charts'])

fout.write(html_content)
html_path = os.path.join(self.report_dir, scene, 'report.html')
logger.info('Generating HTML success : {}'.format(html_path))
return html_path

def make_ios_html(self, scene, summary : dict):
logger.info('Generating HTML ...')
STATICPATH = os.path.dirname(os.path.realpath(__file__))
file_loader = FileSystemLoader(os.path.join(STATICPATH, 'report_template'))
env = Environment(loader=file_loader)
template = env.get_template('ios.html')
with open(os.path.join(self.report_dir, scene, 'report.html'),'w+') as fout:
html_content = template.render(cpu_app=summary['cpu_app'],cpu_sys=summary['cpu_sys'],gpu=summary['gpu'],
mem_total=summary['mem_total'],fps=summary['fps'],
tem=summary['tem'],current=summary['current'],
voltage=summary['voltage'],power=summary['power'],
net_send=summary['net_send'],net_recv=summary['net_recv'],
cpu_charts=summary['cpu_charts'],mem_charts=summary['mem_charts'],
net_charts=summary['net_charts'],battery_charts=summary['battery_charts'],
fps_charts=summary['fps_charts'],gpu_charts=summary['gpu_charts'])
fout.write(html_content)
html_path = os.path.join(self.report_dir, scene, 'report.html')
logger.info('Generating HTML success : {}'.format(html_path))
return html_path


def get_repordir(self):
report_dir = os.path.join(os.getcwd(), 'report')
Expand Down Expand Up @@ -223,6 +265,7 @@ def record_net(self, type, send , recv):
logger.error('record network data failed')

def make_report(self, app, devices, platform='Android', model='normal'):
logger.info('Generating test results ...')
current_time = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
result_dict = {
"app": app,
Expand All @@ -242,6 +285,7 @@ def make_report(self, app, devices, platform='Android', model='normal'):
filename = os.path.join(self.report_dir, f)
if f.split(".")[-1] in ['log', 'json']:
shutil.move(filename, report_new_dir)
logger.info('Generating test results success: {}'.format(report_new_dir))

def instance_type(self, data):
if isinstance(data, float):
Expand Down
Loading

0 comments on commit 25df147

Please sign in to comment.