-Xfrontend -debug-time-function-bodies
在终端中执行以下命令开启:
defaults write com.apple.dt.Xcode ShowBuildOperationDuration YES
通过这样启动 Build: Product -> Perform Action -> Build With Timing Summary, 在 build 结束时,可以在 Xcode 的 Build 日志的末尾看到耗时概要统计。或者使用命令行:
xcodebuild -buildWithTimingSummary
-driver-time-compilation
-Xfrontend -debug-time-function-bodies
-Xfrontend -debug-time-expression-type-checking
-Xfrontend -print-stats
-Xfrontend -print-clang-stats
-Xfrontend -print-stats -Xfrontend -print-inst-counts
可以在 Xcode Build Settings 中的 Other Swift Flags
中加入诊断选项,将超过指定编译时长(如 100 毫秒)的函数、表达式以警告的方式显示出来,方便定位与优化:
-Xfrontend -warn-long-function-bodies=100
-Xfrontend -warn-long-expression-type-checking=100