RUMM-2441 Optimize BaseWireframeMapper#colorAndAlphaAsStringHexa function#1077
Merged
mariusc83 merged 1 commit intoOct 11, 2022
Conversation
0xnm
approved these changes
Oct 10, 2022
xgouchet
reviewed
Oct 10, 2022
Comment on lines
+24
to
+30
| val colorAndAlphaAsHexa = (0xffffffff and colorAndAlpha) | ||
| .toString(16) | ||
| .padStart(8, '0') |
Contributor
There was a problem hiding this comment.
Can you give some details on why this algorithm is more optimized vs the String.format one? Did you benchmark this?
Member
Author
There was a problem hiding this comment.
Yes, I profiled this with the Android Profiler...there is a big difference there.
Member
Author
There was a problem hiding this comment.
Because we are using this function for each tree node...I profiled the whole snapshot function. With the String.format the difference is ~10ms + which is huge.
Contributor
There was a problem hiding this comment.
Maybe it'd be nice to add a comment there to make sure we remember why we use a three line code instead of a one liner ;)
xgouchet
approved these changes
Oct 10, 2022
mariusc83
force-pushed
the
mconstantin/rumm-2441/screen-recorder-optimize-the-color-resolver-function
branch
2 times, most recently
from
October 10, 2022 12:55
4199cea to
b7d11ce
Compare
mariusc83
force-pushed
the
mconstantin/rumm-2441/screen-recorder-optimize-the-color-resolver-function
branch
from
October 10, 2022 13:40
b7d11ce to
d752382
Compare
xgouchet
approved these changes
Oct 10, 2022
Comment on lines
+24
to
+27
| // we are going to use the `Long.toString(radius)` method to produce the hexa | ||
| // representation of the color and alpha long value because is much more faster than the | ||
| // String.format(..) approach. Based on our benchmarks, because String.format uses regular | ||
| // expressions under the hood, this approach is at least 2 times faster. |
mariusc83
deleted the
mconstantin/rumm-2441/screen-recorder-optimize-the-color-resolver-function
branch
October 11, 2022 11:41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
We were using the
String.formatapproach to resolve the shape color, alpha values as a hexa string property and this was quite costly in terms of performances. We are changing this relying on theInt.toString(radius)function which is much more faster.Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
Review checklist (to be filled by reviewers)