xcpretty / xcode-install

🔽 Install and update your Xcodes
https://fastlane.tools
MIT License
2.59k stars 243 forks source link

improve version fetching command performance by reading Xcode's version.plist instead of using the `xcodebuild` command #427

Closed aomathwift closed 3 years ago

aomathwift commented 3 years ago

closes #273 Currently It takes a few ms to run XcodeInstall::Installer.installed_versions. The cause seems to be that xcodebuild command is executed directly in fetch_version method. Therefore, I refer to #273 and change to parse and read the version.plist inside the Xcode.app to detect Xcode version.

For example, if you run xcversion list from CLI and measure the execution time with the time command, the execution time changes as follows:

Before improvement: xcversion list 3.30s user 2.92s system 40% cpu 15.412 total After improvement: xcversion list 1.58s user 0.47s system 96% cpu 2.127 total

As you can see, the execution time has been halved.

aomathwift commented 3 years ago

Can someone review this patch? This changes will have good effect for my project. 🙏

rogerluan commented 3 years ago

My results (ran 3-5 times each, pretty consistent results):

Before: bundle exec xcversion list  0.93s user 0.48s system 58% cpu 2.407 total
After: bundle exec xcversion list  0.70s user 0.31s system 90% cpu 1.117 total

LGTM 🚀

Thank you for your contribution @aomathwift !