Skip to content

Instantly share code, notes, and snippets.

@CyrilCermak
Last active November 21, 2017 00:43
Show Gist options
  • Save CyrilCermak/7e216aff42f32fe61baca90f75a45dcb to your computer and use it in GitHub Desktop.
Save CyrilCermak/7e216aff42f32fe61baca90f75a45dcb to your computer and use it in GitHub Desktop.
Swift compile time analyse
This is a quick tutorial for analysing Swift compile time.
3 main steps:
1) Log the whole app build:
xcodebuild -workspace ./App.xcworkspace -scheme App clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | tee ~/Desktop/compile_log.txt
2) Get sorted data we want from build:
grep '^\d*\.\d*ms' compile_log.txt | sort -n -k1 -r > compile_analyzed.txt
3) Make it more readable
cat compile_analyzed.txt | cut -f1 -f2 | grep -v "<invalid loc>" | awk '{gsub("Path/To/Project/", "")}1'
Note:
In my case compiler came out with a milions of <invalid loc>, I think it could be jumping around compiling closures or something like that.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment