Faster ISO date formatter / parser#5070
Merged
DanielNovak merged 2 commits intodevelopfrom Nov 20, 2023
Merged
Conversation
74d3635 to
33a1bbd
Compare
33a1bbd to
5a0d435
Compare
JcMinarro
reviewed
Nov 20, 2023
...ndroid-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/helper/DateFormatter.kt
Show resolved
Hide resolved
This was referenced Nov 24, 2023
16 tasks
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.
Our API is currently quite heavy on the usage ISO date which are notoriously slow to parse. There is a plan to replace this with Unix timestamps but in the short term we can use a small ISO parser and formatter - https://github.com/ethlo/itu/ . According to the docs and also to my tests the speed is significantly faster - up 10x, in our API response parsing scenario it seems to be "only" 4x faster than the Java Instant but that is still a massive saving.
I have also added the usage of Instant into our util DateTimeFormatter. This one is used from our Compose components and while the absolute time saving is minimal (5ms vs ~3ms) on each item drawn - it still can make a difference because this is done on the UI thread.
In the long run we will make the JSON structure more efficient and replace the ISO date with Unix timestamps, but until that this is worthy upgrade.