Improve performance when parsing many strings in the same format#28
Open
robin-xyzt-ai wants to merge 5 commits intosisyphsu:masterfrom
Open
Improve performance when parsing many strings in the same format#28robin-xyzt-ai wants to merge 5 commits intosisyphsu:masterfrom
robin-xyzt-ai wants to merge 5 commits intosisyphsu:masterfrom
Conversation
akash-yadagouda
approved these changes
Feb 16, 2023
akash-yadagouda
left a comment
There was a problem hiding this comment.
bit more explanation on code.
* Some additional comments * Some small tweaks to the code in an attempt to improve readability * Extended the test case a bit
Author
|
I tried to make the code a bit more clear by leaving some additional comments and doing a bit more code cleanup. Let me know if there are specific parts that are still unclear. |
robin-xyzt-ai
commented
Feb 17, 2023
pom.xml
Outdated
|
|
||
| <groupId>com.github.sisyphsu</groupId> | ||
| <artifactId>dateparser</artifactId> | ||
| <artifactId>dateparser-xyzt-ai</artifactId> |
Author
There was a problem hiding this comment.
Ow, this was a mistake.
This was done for our local fork, and should not have been included in this PR. Will revert this for the PR.
Author
|
Looks like this PR isn't ready to be merged. The following test fails: @Test
void foo() {
DateParser parser = DateParser.newBuilder().optimizeForReuseSimilarFormatted(true).build();
String inputString = "2022-08-09 19:04:31.600000+00:00";
assertEquals(parser.parseDate(inputString), parser.parseDate(inputString));
}I'm afraid it will require a fix for #29 first. |
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.
Proposal for #17 .
By keeping track of which rules were used to parse the first string, parsing the next strings can try to use a matcher that only uses a subset of those rules.
The case in the benchmark is between 2 and 3 times faster on my machine: