-
Notifications
You must be signed in to change notification settings - Fork 24
Improve performance when parsing many strings in the same format #28
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
Open
robin-xyzt-ai
wants to merge
5
commits into
sisyphsu:master
Choose a base branch
from
xyzt-ai:parse-similar-strings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
725049d
Improve performance when parsing many strings in the same format
b40d10f
Improve performance when parsing many strings in the same format
4d4bd8c
Merge remote-tracking branch 'origin/parse-similar-strings' into pars…
84fd1e3
Clarified the code some more
8a9da3b
Restored the pom.xml to the original version
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,3 +23,6 @@ | |
| hs_err_pid* | ||
| .idea | ||
| *.iml | ||
|
|
||
| # Output folder of IntelliJ | ||
| target | ||
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
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
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
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
44 changes: 44 additions & 0 deletions
44
...a/com/github/sisyphsu/dateparser/benchmark/OptimizeForReuseSimilarFormattedBenchmark.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| package com.github.sisyphsu.dateparser.benchmark; | ||
|
|
||
| import com.github.sisyphsu.dateparser.DateParser; | ||
| import org.openjdk.jmh.annotations.*; | ||
|
|
||
| import java.util.Random; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| @Warmup(iterations = 2, time = 2) | ||
| @BenchmarkMode(Mode.AverageTime) | ||
| @Fork(2) | ||
| @Measurement(iterations = 3, time = 3) | ||
| @OutputTimeUnit(TimeUnit.MILLISECONDS) | ||
| public class OptimizeForReuseSimilarFormattedBenchmark { | ||
| private static final String[] TEXTS; | ||
|
|
||
| static { | ||
| Random random = new Random(123456789l); | ||
| TEXTS = new String[500000]; | ||
| for (int i = 0; i < TEXTS.length; i++) { | ||
| TEXTS[i] = String.format("2020-0%d-1%d 00:%d%d:00 UTC", | ||
| random.nextInt(8) + 1, | ||
| random.nextInt(8) + 1, | ||
| random.nextInt(5), | ||
| random.nextInt(9)); | ||
| } | ||
| } | ||
|
|
||
| @Benchmark | ||
| public void regularParser() { | ||
| DateParser parser = DateParser.newBuilder().build(); | ||
| for (String text : TEXTS) { | ||
| parser.parseDate(text); | ||
| } | ||
| } | ||
|
|
||
| @Benchmark | ||
| public void optimizedForReuseParser() { | ||
| DateParser parser = DateParser.newBuilder().optimizeForReuseSimilarFormatted(true).build(); | ||
| for (String text : TEXTS) { | ||
| parser.parseDate(text); | ||
| } | ||
| } | ||
| } |
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.
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.
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.