Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jun 15, 2021

Conversation

aomathwift
Copy link
Contributor

@aomathwift aomathwift commented Apr 21, 2021

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
Copy link
Contributor Author

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

Copy link
Collaborator

@rogerluan rogerluan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great! Thanks for picking up this improvement suggested a long time ago 🤩

@rogerluan rogerluan changed the title Use the version.plist to detect Xcode version in fetch_version improve version fetching command performance by reading Xcode's version.plist instead of using the xcodebuild command Jun 15, 2021
@rogerluan
Copy link
Collaborator

rogerluan commented Jun 15, 2021

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 !

@rogerluan rogerluan merged commit eeb8a07 into xcpretty:master Jun 15, 2021
@aomathwift aomathwift deleted the fetch-version-faster branch June 16, 2021 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use the Info.plist instead of the xcodebuild command to detect Xcode version
3 participants