Skip to content

Instantly share code, notes, and snippets.

@Lutzifer
Last active May 13, 2016 08:28
Show Gist options
  • Save Lutzifer/64c00ddf839b866a81274496fa48de04 to your computer and use it in GitHub Desktop.
Save Lutzifer/64c00ddf839b866a81274496fa48de04 to your computer and use it in GitHub Desktop.
Analyze compile time per function in xcode project. This work is based on http://irace.me/swift-profiling
#call with workspace name and scheme as arguments
xcodebuild -workspace $1.xcworkspace -scheme $2 clean build CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" > buildlog.txt
function filteredOutput() {
echo $1
cat buildlog.txt | \
#only lines including ms
grep "[0-9].[0-9]ms" | \
#apply filter
$1 | \
#replace ms
sed "s|ms||g" | \
#run awk script with delimiter space
awk -F ' ' '{\
a[$2] += $1;\
b[$2] += 1;\
total += $1}\
END{\
for (i in a) print a[i],\
b[i],\
i, \
total\
}' | \
# sort output numerical by first column
sort -n
}
mkdir buildAnalysis
# main app witout pods
filteredOutput "grep -v Pods" > buildAnalysis/main.txt
#every pod on its own
for pod in Pods/*
do
filteredOutput "grep $pod" > buildAnalysis/AnalyzedPod$(basename $pod).txt
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment