网络知识 娱乐 性能测试:手机IOS性能测试

性能测试:手机IOS性能测试

获取IOS性能参数可以基于python的第三方库py-ios-device,该库需要pyhton3.7+的支持。在官方下载好对应版本的python后,把它加入到系统环境变量中。再借助python的pip工具进行第三方库的下载,在下载前,需要先更新pip到最新版。

1、更新到最新版pip,cmd执行命令:python -m install --upgrade pip

2、下载py-ios-device,执行命令:pip install py-ios-device(因为是国外网站,可能出现timeout问题,可以在国内网站下载,pip install py-ios-device -i https://pypi.mirrors.ustc.edu.cn/simple/)

3、下载tidevice:pip install tidevice(通过tidevice app list获取测试app的bundle_id),完成后执行:pyidevice即可出现对应得命令参数列表

py-ios-device提供了对应的方法获取到专项对应数据,如:1、cpu 2、memory 3、net 4、disk 5、Fps 6、设备的功耗(电流,电压,功率,温度等) 7、syslog,crashlog 8、栈快照等

4、常用命令

pyidevice devices,获取设备uuid信息

pyidevice deviceinfo --uuid=? 获取对应设备的信息

tidevice applist 获取app的bundle_id

性能项测试:

1、冷热启动时间

需要通过录屏+数帧的方式粗略估算,可用potplayer软件。

2、系统级Io、Memory、Cpu

输入命令:pyidevice instruments monitor(数据1s刷新一次)

可以通过--filter命令过滤数据

pyidevice instruments monitor --filter=cpu

3、进程级Io、Memory、Cpu

输入命令:pyidevice sysmontap -b 包名

可以通过 --proc_filter 命令过滤信息:

pyidevice sysmontap -b 包名 --proc_filter memVirtualSize,cpuUsage --processes --sort cpuUsage

4、获取网络io数据

pyidevice instruments networking

该命令可以直接获取对应设备的ip,接收缓冲区使用情况,收发包的数量,接收和发送的数据量

还能通过:pyidevice instruments network_process -b 包名

获取对应app的网络数据:发送和接收的流量,收发包的数量

5、获取ios帧率

pyidevice instruments fps

pyidevice还提供了对应的api能够标记出对应操作的卡顿情况,但是目前只能通过api调用才能获取。

6、获取功耗

pyidevice battery

显示信息较多,可直接关注最后一行汇总数据

7、弱网测试

pyidevice可直接模拟出对应的弱网条件,在模拟之前需要先获取所有可模拟的网络事件

pyidevice instruments condition get 命令可得可模拟的网络事件

pyidevice instruments condition set -c conditionName -p identifierName

conditionName主要有以下两类:SlowNetworkCondition 或 ThermalCondition(设置系统状态处于高性能状态)

模拟2g网络

pyidevice instruments condition set -c SlowNetworkCondition -p SlowNetwork2GUrban

模拟3g网络

pyidevice instruments condition set -c SlowNetworkCondition -p SlowNetwork3GGood

8、获取日志信息

获取系统栈的快照信息:pyidevice instruments stackshot --out filepath+filename

获取系统日志:pyidevice syslog --path filepath+filename(可通过--filter过滤信息)