-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Reduce build time with minor reference refactor #2679
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2679 +/- ##
==========================================
- Coverage 19.65% 19.65% -0.01%
==========================================
Files 112 112
Lines 13717 13715 -2
==========================================
- Hits 2696 2695 -1
+ Misses 11021 11020 -1
Continue to review full report at Codecov.
|
Hi there, thanks for the input. Do you have any doc or post could explain this change? |
The part at the bottom of this article references a similar problem, where chaining operations can sometimes cause dramatic increases in compile time (also referenced by an Apple build engineer at WWDC). For the |
Bump |
Thank you for your information. I'm fine with this PR, but also needs other peoples' review. BTW, if it helps, do we need to change the entire code base? |
There are certainly other parts of the code that can be optimized but these two lines were taking the longest amount of time (over 2 seconds if being used as a cocoapod). So I only tackled these two as the easiest way to cut down a somewhat significant part of the build time. |
return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * (viewPortHandler?.scaleX ?? 1.0)) | ||
|
||
let maxVisibleCount = CGFloat(dataProvider?.maxVisibleCount ?? 0) | ||
let scale = self.viewPortHandler?.scaleX ?? 1.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got self
is improving the speed. But can we just uses self, without using two instants? like
return data.entryCount < Int(CGFloat(dataProvider?.maxVisibleCount ?? 0) * (self.viewPortHandler?.scaleX ?? 1.0))
I assume it has the same effect?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The self
change does account for most of the improvements. Chained operations do tack on some build time increase but it's probably not significant for this case. Happy to go ahead and update with that change.
Adding a `self.` reference to a instance variable reduced the compile time significantly (over 10x improvement). A single line evaluation of a variable was further broken out into separate steps to reduce the compile time as well.
a9c1f1d
to
80a45c0
Compare
Cool! Thanks! |
Reduce build time with minor reference refactor
Adding a
self.
reference to a instance variable reduced the compiletime significantly (over 10x improvement). A single line evaluation of a
variable was further broken out into separate steps to reduce the
compile time as well.
This cuts at least 2 seconds from the build time
Compile times were analyzed with the following bash command:
xcodebuild -scheme Charts -sdk iphonesimulator PLATFORM_NAME=iphonesimulator clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" 2>&1 | grep -e [0-9][0-9].[0-9].ms | sort -nr
Compile times before the change:
Compile times after the change: