Package: antpy-ios-device
py-ios-deviceA python based Apple instruments protocol，you can get CPU, Memory and other metrics from real iOS deviceslink:https://testerhome.com/topics/27159中文文档Java link:https://github.com/YueChen-C/java-ios-device)pip :pip install py-ios-devicepython version: 3.7 +Instruments：Get system Memory and CPU dataGet processes Memory and CPU dataGet FPS dataGet network dataSet the device network status. eg: 2G, 3G ,100% LossSet the device behaves as though under a high thermal stateMonitoring app start、exit、backgroundLaunch and Kill appRun xctest. eg: WebDriverAgentDump core profile stack snapshotAnalyze the core profile data streamGet Metal GPU CountersOtherProfiles & Device Management. eg: Install and uninstall Fiddler certificateGet syslogGet crash logGet the captured packet traffic and forward it to wiresharkApp install and uninstallGet device batteryUsage：pip :> pip install py-ios-device
> pyidevice --help
> pyidevice instruments --helpGet device list$pyidevicedevicesGet device info$pyidevice--udid=xxxxxxdeviceinfoGet System performance data$pyideviceinstrumentsmonitorMemory>>{'App Memory':'699.69 MiB','Cached Files':'1.48 GiB','Compressed':'155.17 MiB','Memory Used':'1.42 GiB','Wired Memory':'427.91 MiB','Swap Used':'46.25 MiB'}Network>>{'Data Received':'4.07 GiB','Data Received/sec':'4.07 GiB','Data Sent':'2.54 GiB','Data Sent/sec':'2.54 GiB','Packets in':2885929,'Packets in/sec':6031576,'Packets Out':2885929,'Packets Out/sec':2885929}Disk>>{'Data Read':'117.91 GiB','Data Read/sec':0,'Data Written':'64.28 GiB','Data Written/sec':0,'Reads in':9734132,'Reads in/sec':9734132,'Writes Out':6810640,'Writes Out/sec':6810640}$pyideviceinstrumentsmonitor--filter=memory
Memory>>{'App Memory':'699.69 MiB','Cached Files':'1.48 GiB','Compressed':'155.17 MiB','Memory Used':'1.42 GiB','Wired Memory':'427.91 MiB','Swap Used':'46.25 MiB'}Get Processes performance data$pyideviceinstrumentssysmontap--help
$pyideviceinstrumentssysmontap-bcom.tencent.xin--proc_filtermemVirtualSize,cpuUsage--processes--sortcpuUsage# 只显示 memVirtualSize,cpuUsage 参数的进程列表，且根据 cpuUsage 字段排序[('WeChat',{'cpuUsage':0.03663705586691998,'memVirtualSize':2179284992,'name':'WeChat','pid':99269})][('WeChat',{'cpuUsage':0.036558268613227536,'memVirtualSize':2179284992,'name':'WeChat','pid':99269})]Get FPS data$pyideviceinstrumentsfps{'currentTime':'2021-05-11 14:14:40.259059','fps':52}{'currentTime':'2021-05-11 14:14:40.259059','fps':56}Get network data$pyideviceinstrumentsnetworking# Get all network data"connection-update{\"RxPackets\": 2, \"RxBytes\": 148, \"TxPackets\": 2, \"TxBytes\": 263, \"RxDups\": 0, \"RxOOO\": 0, \"TxRetx\": 0, \"MinRTT\": 0.05046875, \"AvgRTT\": 0.05046875, \"ConnectionSerial\": 5}""connection-update{\"RxPackets\": 4, \"RxBytes\": 150, \"TxPackets\": 3, \"TxBytes\": 1431, \"RxDups\": 0, \"RxOOO\": 0, \"TxRetx\": 0, \"MinRTT\": 0.0539375, \"AvgRTT\": 0.0541875, \"ConnectionSerial\": 4}"$pyideviceinstrumentsnetwork_process-pcom.tencent.xin# Get application network data{403:{'net.packets.delta':119,'time':1620720061.0643349,'net.tx.bytes':366715,'net.bytes.delta':63721,'net.rx.packets.delta':47,'net.tx.packets':633,'net.rx.bytes':34532,'net.bytes':401247,'net.tx.bytes.delta':56978,'net.rx.bytes.delta':6743,'net.rx.packets':169,'pid':403,'net.tx.packets.delta':72,'net.packets':802}}{403:{'net.packets.delta':13,'time':1620720076.2191892,'net.tx.bytes':1303204,'net.bytes.delta':5060,'net.rx.packets.delta':5,'net.tx.packets':2083,'net.rx.bytes':46736,'net.bytes':1349940,'net.tx.bytes.delta':4682,'net.rx.bytes.delta':378,'net.rx.packets':379,'pid':403,'net.tx.packets.delta':8,'net.packets':2462}}Set device status. iOS version > 12$pyideviceinstrumentsconditionget# Get device configuration information$pyideviceinstrumentsconditionset-cSlowNetworkCondition-pSlowNetwork2GUrban# Set the device network status. eg: 2G, 3G ,100% Loss$pyideviceinstrumentsconditionset-cThermalCondition-pThermalCritical# Set the device behaves as though under a high thermal stateListen to app notifications$pyideviceinstrumentsnotifications[{'execName':'MobileNotes','state_description':'Foreground Running','elevated_state_description':'Foreground Running','displayID':'com.apple.mobilenotes','mach_absolute_time':27205542653928,'appName':'Notes','elevated_state':8,'timestamp':1620714619.1264,'state':8,'pid':99367}][{'execName':'MobileNotes','state_description':'Background Running','elevated_state_description':'Background Running','displayID':'com.apple.mobilenotes','mach_absolute_time':27205678872050,'appName':'Notes','elevated_state':4,'timestamp':1620714624.802145,'state':4,'pid':99367}][{'execName':'MobileNotes','state_description':'Background Task Suspended','elevated_state_description':'Background Task Suspended','displayID':'com.apple.mobilenotes','mach_absolute_time':27205683486410,'appName':'Notes','elevated_state':2,'timestamp':1620714624.99441,'state':2,'pid':99367}]Dump core profile stack snapshot$instrumentsstackshot--outstackshot.logAnalyze the core profile data stream$instrumentsinstrumentscore_profile--pid=1107SealTalk(1107)PERF_THD_CSwitch(0x25010014)DBG_PERFPERF_DATADBG_FUNC_NONESealTalk(1107)MACH_DISPATCH(0x1400080)DBG_MACHDBG_MACH_SCHEDDBG_FUNC_NONESealTalk(1107)DecrSet(0x1090004)DBG_MACHDBG_MACH_EXCP_DECIDBG_FUNC_NONEGet Metal GPU Counters$instrumentsgpu_counters15.132907ALULimiter93.7715.132907TextureSampleLimiter39.6215.132907TextureWriteLimiter13.8715.132907BufferReadLimiter0.0115.132907BufferWriteLimiter015.132907Threadgroup/ImageblockLoadLimiter17.1615.132907Threadgroup/ImageblockStoreLimiter10.915.132907FragmentInputInterpolationLimiter15.7415.132907GPULastLevelCacheLimiter6.2415.132907VertexOccupancy015.132907FragmentOccupancy91.4415.132907ComputeOccupancy015.132907GPUReadBandwidth2.6515.132907GPUWriteBandwidth1.25OtherProfiles & Device Management$pyideviceprofileslist{"OrderedIdentifiers":["aaaff7e2b7df39eeb77bfbc0cd7a70ea99f3fd97a"],"ProfileManifest":{"aaaff7e2b7df39eeb77bfbc0cd7a70ea99f3fd97a":{"Description":"DO_NOT_TRUST_FiddlerRoot","IsActive":true}},"ProfileMetadata":{"aaaff7e2b7df39eeb77bfbc0cd7a70ea99f3fd97a":{"PayloadDisplayName":"DO_NOT_TRUST_FiddlerRoot","PayloadRemovalDisallowed":false,"PayloadUUID":"C8CE7BC1-F840-4616-B606-337F8CB6AE19","PayloadVersion":1}},"Status":"Acknowledged"}$pyideviceprofilesinstall--pathDownloads/charles-certificate.pem## install charles certificate$pyideviceprofilesremove--namefe7371d9ce36c541ac8dee5f51f3b490b2aa98dcd95699ee44717fd5233fe7a0a## uninstall charles certificateget syslog$pyidevicesyslog# --path# --filterget crash syslog$pyidevicecrashlist['.','..','com.apple.appstored','JetsamEvent-2021-05-12-112126.ips']$pyidevicecrashexport--nameJetsamEvent-2021-05-12-112126.ips

$pyidevicecrashdelete--nameJetsamEvent-2021-05-12-112126.ips

$pyidevicecrashshellapps$pyideviceappslist

$pyideviceappsinstall--ipa_path

$pyideviceappsuninstall--bundle_id$pyideviceappslaunch--bundle_id

$pyideviceappskill--bundle_id

$pyideviceappsshellpacket traffic$pyidevicepcapd./test/test.pacp

$pyidevicepcapd-|"/Applications/Wireshark.app/Contents/MacOS/Wireshark"-k-i-# mac forword Wireshark$pyidevicepcapd-|"D:\Program Files\Wireshark\Wireshark.exe"-k-i-# win forword Wiresharkdevice battery$pyidevicebattery# [Battery] time=1622777708, current=-71, voltage=4330, power=-307.43, temperature=3279enable developer mode$pyideviceenable_developer_modeQQ ：37042417api :documentdemo:document