iOS 编译时长分析

使用到的工具 :

xcpretty https://github.com/supermarin/xcpretty
gnomon https://rubygems.org/gems/gnomon/versions/1.0.0

xcpretty 安装:gem install xcpretty
gnomon 安装:npm install -g gnomon

实际操作

一、估算使用命令:
xcodebuild -workspace YourName.xcworkspace -scheme YourName -archivePath ~/Desktop/Dianfubao archive |xcpretty | gnomon

二、然后我们的终端会有一个每个文件编译时长的列表,把这些时间拷贝到一个文本文件如result.txt,然后再执行些命令

sort -n -k1 result.txt

来源:http://www.jianshu.com/p/e2ff8da95c42

更新:鉴于以上的操作在想要分析十次的情况下,会显得很麻烦,所以我写了一个脚本来让它自动执行这些操作。
脚本内容

#!/bin/sh
myFile="./result.txt"
myFile2="./resultSorted.txt"
if [ ! -f "$myFile" ]; then
touch "$myFile"
else
rm -rf "$myFile"
fi
if [ ! -f "$myFile2" ]; then
touch "$myFile2"
else
rm -rf "$myFile2"
fi
xcodebuild -workspace YourName.xcworkspace -scheme YourName -archivePath ~/Desktop/YourName archive |xcpretty | gnomon 1> "$myFile" &&
sort -n -k1 result.txt 1> "$myFile2"
wait

命令1 &&
命令2
wait
是指等待上个任务完成后再执行下个任务
命令 1> "$myFile2"
是指将命令在终端上的输出内容 完整地输出到 某个文件里去

image.png

执行脚本,然后等待完成 后,我们就直接查看resultSorted.txt这个文件内的内容就行了,已经是最新的排序后的样子了。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容