今天想著對(duì)新項(xiàng)目進(jìn)行啟動(dòng)時(shí)間監(jiān)測(cè),但是發(fā)現(xiàn)控制臺(tái)一直沒辦法打印啟動(dòng)時(shí)間信息,DYLD_PRINT_STATISTICS為1根本不管用,于是乎查了一些文章最后找到了原因:Xcode 13.0 beta / iOS 15.0 以后的版本都不能打印相關(guān)啟動(dòng)時(shí)間相關(guān)信息了。以前用著還是很方便的,但你以后不能用了。
原因:iOS 15 and macOS Monterey have a new version of dyld. You can see the man page for dyld in macOS Monterey to see the current set of environment variables that you can use.
Several years ago, the Time Profiler instrument gained the ability to profile the time spent during app launch before main(). You should profile your app launches this way instead.
翻譯:iOS15和macOS Monterey有一個(gè)新版本的dyld,然后讓你用profile里面的instrument工具去監(jiān)測(cè),工具是有這個(gè)能力的。
連接:https://developer.apple.com/forums/thread/689581
前面說的基本都是廢話,下面我們來說正文:
使用instrument工具進(jìn)行監(jiān)測(cè),蘋果的instrument工具非常的強(qiáng)大,而且好用,以后得習(xí)慣使用起來了。
找到App Launch,然后運(yùn)行起來,等待app自己?jiǎn)?dòng),然后推出,recording結(jié)束以后,同步完成;就顯示出來我們需要的內(nèi)容了:

重點(diǎn)標(biāo)出來了,然后下面的時(shí)間就是我們啟動(dòng)的具體時(shí)間了。
關(guān)于啟動(dòng)時(shí)間的分析和優(yōu)化,后面我會(huì)寫一篇文章專門去說明