Skip to content

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

Merged
rogerluan merged 3 commits into
xcpretty:masterfrom
aomathwift:fetch-version-faster
Jun 15, 2021
Merged

improve version fetching command performance by reading Xcode's version.plist instead of using the xcodebuild command#427
rogerluan merged 3 commits into
xcpretty:masterfrom
aomathwift:fetch-version-faster

Conversation

@aomathwift

@aomathwift aomathwift commented Apr 21, 2021

Copy link
Copy Markdown
Contributor

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

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

@rogerluan rogerluan left a comment

Copy link
Copy Markdown
Collaborator

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

rogerluan commented Jun 15, 2021

Copy link
Copy Markdown
Collaborator

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