在build setting的Other Swift Flags中添加以下flag,就可在building log中看到详细的编译时长:
-Xfrontend -debug-time-compilation:输出文件的编译时长
-Xfrontend -debug-time-function-bodies:输出function编译时长
-Xfrontend -debug-time-expression-type-checking:输出function内每一行代码的编译时长
-Xfrontend -warn-long-function-bodies=100:编译时间超过100ms的function报警告
-Xfrontend -warn-long-expression-type-checking=100:编译时间超过100ms的代码报警告
日志通常都有数十万行,可阅读性极差。GitHub上有个工具能够方便的统计展现这些日志信息,连接以下: github.com/fastred/Opt…
使用flag和对应的工具能够定位到具体编译时间特长的代码的位置,相应的进行修改就能解决代码层面的编码时间长的问题。git
参考文档比我写的详细,我只是将这些文档实践,而后总结一下有用的东西。
koke.me/2017/03/24/…
hackernoon.com/speed-up-sw…
github.com/fastred/Opt…
工具连接: github.com/RobertGumme…github