pymobiledevice3 icon indicating copy to clipboard operation
pymobiledevice3 copied to clipboard

Measuring the Application Launch Time

Open huan1936 opened this issue 1 year ago • 3 comments

Is it feasible to determine the startup duration of an application using pymobiledevice3?

I understand that by emulating Xcode and integrating DYLD_PRINT_STATISTICS, one can achieve a detailed printout of the time spent during various stages of the process. In theory, this approach should be supported.

However, it appears that this method may not be compatible with iOS versions above 15.

huan1936 avatar Jul 14 '24 10:07 huan1936

I don't know wether this is best way, but you can still launch applications with whatever env variables you want:

pymobiledevice3 developer dvt launch com.apple.calculator --env DYLD_PRINT_STATISTICS 1

doronz88 avatar Jul 14 '24 10:07 doronz88

I don't know wether this is best way, but you can still launch applications with whatever env variables you want:我不知道这是否是最好的方法,但您仍然可以使用所需的任何环境变量启动应用程序:

pymobiledevice3 developer dvt launch com.apple.calculator --env DYLD_PRINT_STATISTICS 1pymobiledevice3 开发者 dvt 启动 com.apple.calculator --env DYLD_PRINT_STATISTICS 1

In IOS 15.0 and below, it can output the boot time, but in versions above 15.0, it doesn't. It seems to be because of this https://forums.developer.apple.com/forums/thread/689581

arguments = []
env = {
    'DYLD_PRINT_STATISTICS': '1'
}
with DvtSecureSocketProxyService(lockdown=lockdown) as dvt:
    process_control = ProcessControl(dvt)
    pid = process_control.launch(bundle_id=test_bundle_id, arguments=arguments,
                                 kill_existing=True,
                                 start_suspended=False,
                                 environment=env)
    print(f'Process launched with pid {pid}')
    for output_received in process_control:
        print(output_received.message)

out

Total pre-main time:  99.75 milliseconds (100.0%)
         dylib loading time:  14.13 milliseconds (14.1%)
        rebase/binding time:   9.72 milliseconds (9.7%)
            ObjC setup time:   2.90 milliseconds (2.9%)
           initializer time:  72.99 milliseconds (73.1%)
           slowest intializers :
             libSystem.B.dylib :   3.37 milliseconds (3.3%)
     substitute-inserter.dylib :  37.25 milliseconds (37.3%)

huan1936 avatar Jul 26 '24 03:07 huan1936

https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes

huan1936 avatar Jul 26 '24 04:07 huan1936