:chart_with_upwards_trend: CLI 用于分析 Swift 项目的编译时间
Command line utility to profile compilation time of Swift project.
This tool is developed in working time for Cookpad.
gem install xcprofilerxcprofiler is tested on latest Ruby 2.3/2.4.
Add -Xfrontend -debug-time-function-bodies build flags in Build Settings -> Other Swift Flags section of your Xcode project.
Build your project
Execute xcprofiler
$ xcprofiler [PRODUCT_NAME or ACTIVITY_LOG_PATH] [options]xcprofiler searches the latest build log on your DerivedData directory.
You can also specify the .xcactivitylog.
$ xcprofiler MyApp
$ xcprofiler ~/Library/Developer/Xcode/DerivedData/MyApp-xxxxxxxxxxx/Logs/Build/0761C73D-3B6C-449A-BE89-6D11DAB748FE.xcactivitylogSample output is here
…| option | shorthand | description |
|---|---|---|
| --limit | -l | Limit for display |
| --threshold | Threshold of time to display (ms) | |
| --show-invalids | Show invalid location results | |
| --order | -o | Sort order (default,time,file) |
| --derived-data-path | Root path of DerivedData directory | |
| --truncate-at | -t | Truncate the method name with specified length |
| --no-unique | Show the duplicated results |
You can use reporters to output tracking logs.
require 'xcprofiler'
profiler = Xcprofiler::Profiler.by_product_name('MyApp')
profiler.reporters = [
Xcprofiler::StandardOutputReporter.new(limit: 20, order: :time),
Xcprofiler::JSONReporter.new(output_path: 'result.json'),
Xcprofiler::BlockReporter.new do |executions|
do_something(executions)
end,
]
profiler.report!You can also implement your own reporters.
See implementation of built-in reporters for detail.
You can integrate xcprofiler to danger.
https://github.com/giginet/danger-xcprofiler
MIT License
Bug reports and pull requests are welcome on GitHub at https://github.com/giginet/xcprofiler.
暂无开放 Issues,或尚未同步最近议题。