diff --git a/README.md b/README.md index 1f777bd..1a3178a 100644 --- a/README.md +++ b/README.md @@ -74,8 +74,7 @@ from solox.public.common import Devices d = Devices() pids = d.getPid(deviceId='ca6bd5a5', pkgName='com.bilibili.app.in') # for android -apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', - surfaceview=True, noLog=True, pid=None) +apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True, noLog=False, pid=None, record=False, collect_all=False) # apm = AppPerformanceMonitor(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) @@ -91,8 +90,8 @@ gpu = apm.collectGpu() # % only supports ios # ************* Collect all performance parameter ************* # if __name__ == '__main__': - apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True, noLog=False, pid=None, record=False) - # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS', deviceId='xxxx', noLog=False, record=False) + apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True, noLog=False, pid=None, record=False, collect_all=True) + # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS', deviceId='xxxx', noLog=False, record=False, collect_all=True) #record: record android screen apm.collectAll() # will generate HTML report diff --git a/README.zh.md b/README.zh.md index d486fc9..6553807 100644 --- a/README.zh.md +++ b/README.zh.md @@ -74,8 +74,7 @@ from solox.public.common import Devices d = Devices() pids = d.getPid(deviceId='ca6bd5a5', pkgName='com.bilibili.app.in') # for android -apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', - surfaceview=True, noLog=True, pid=None) +apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True, noLog=False, pid=None, record=False, collect_all=False) # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS') only supports one device # surfaceview: False = gfxinfo (开发者 - GPU渲染模式 - adb shell dumpsys gfxinfo) # noLog : False (保存测试数据到log文件中) @@ -91,8 +90,8 @@ gpu = apm.collectGpu() # % 只支持ios # ************* Collect all performance parameter ************* # if __name__ == '__main__': - apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True, noLog=False, pid=None, record=False) - # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS', deviceId='xxxx', noLog=False, record=False) + apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in',platform='Android', deviceId='ca6bd5a5', surfaceview=True, noLog=False, pid=None, record=False, collect_all=True) + # apm = AppPerformanceMonitor(pkgName='com.bilibili.app.in', platform='iOS', deviceId='xxxx', noLog=False, record=False, collect_all=True) # record: 是否录制 apm.collectAll() # will generate HTML report diff --git a/solox/__init__.py b/solox/__init__.py index 811164d..529b8ee 100644 --- a/solox/__init__.py +++ b/solox/__init__.py @@ -2,4 +2,4 @@ from __future__ import absolute_import -__version__ = '2.8.2' +__version__ = '2.8.3' diff --git a/solox/public/apm.py b/solox/public/apm.py index 8701c60..9b3488e 100644 --- a/solox/public/apm.py +++ b/solox/public/apm.py @@ -447,7 +447,7 @@ class AppPerformanceMonitor(initPerformanceService): """for python api""" def __init__(self, pkgName=None, platform=Platform.Android, deviceId=None, - surfaceview=True, noLog=True, pid=None, record=False): + surfaceview=True, noLog=True, pid=None, record=False, collect_all=False): self.pkgName = pkgName self.deviceId = deviceId self.platform = platform @@ -455,6 +455,7 @@ def __init__(self, pkgName=None, platform=Platform.Android, deviceId=None, self.noLog = noLog self.pid = pid self.record = record + self.collect_all = collect_all d.devicesCheck(platform=self.platform, deviceid=self.deviceId, pkgname=self.pkgName) def collectCpu(self): @@ -464,6 +465,8 @@ def collectCpu(self): appCpuRate, systemCpuRate = _cpu.getCpuRate(noLog=self.noLog) result = {'appCpuRate': appCpuRate, 'systemCpuRate': systemCpuRate} logger.info(f'cpu: {result}') + if self.collect_all is False: + break return result def collectMemory(self): @@ -473,6 +476,8 @@ def collectMemory(self): total, native, dalvik = _memory.getProcessMem(noLog=self.noLog) result = {'total': total, 'native': native, 'dalvik': dalvik} logger.info(f'memory: {result}') + if self.collect_all is False: + break return result def collectBattery(self): @@ -485,6 +490,8 @@ def collectBattery(self): else: result = {'temperature': final[0], 'current': final[1], 'voltage': final[2], 'power': final[3]} logger.info(f'battery: {result}') + if self.collect_all is False: + break return result def collectFlow(self, wifi=True): @@ -497,6 +504,8 @@ def collectFlow(self, wifi=True): upFlow, downFlow = _flow.getNetWorkData(wifi=wifi,noLog=self.noLog) result = {'send': upFlow, 'recv': downFlow} logger.info(f'network: {result}') + if self.collect_all is False: + break return result def collectFps(self): @@ -506,6 +515,8 @@ def collectFps(self): fps, jank = _fps.getFPS(noLog=self.noLog) result = {'fps': fps, 'jank': jank} logger.info(f'fps: {result}') + if self.collect_all is False: + break return result def collectGpu(self): @@ -517,6 +528,8 @@ def collectGpu(self): gpu = _gpu.getGPU(noLog=self.noLog) result = {'gpu': gpu} logger.info(f'gpu: {result}') + if self.collect_all is False: + break return result def setPerfs(self):