Introduce FakeValuesContext and FAKE_VALUES_MAP #767
Merged
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.
The idea behind this PR is to init FakeValues only once per FakeValuesContext (determined by locale, path, url, filename),
right now it generates new FakeValues each time if it is not a default locale
It will allow to reduce GC/memory cost.
Also it was mentioned at #759 at these comments #759 (comment) and #759 (comment)
The best benchmark illustrating improvement is time consumed for build (since junit5 tests in datafaker are running in concurrent mode)
e.g. here for this PR for ubuntu jdk17 it took 1 min, 0 sec[1] vs 1min 18 sec for the latest main[2]
same for jdk20 this PR [3] took 57 sec vs 1 min 14 sec for the latest main [4]
also locally
mvn clean verify
is about 10-15% faster[1] https://github.com/datafaker-net/datafaker/actions/runs/4707215086/jobs/8348951734?pr=767#step:4:966
[2] https://github.com/datafaker-net/datafaker/actions/runs/4700592603/jobs/8335491257#step:4:967
[3] https://github.com/datafaker-net/datafaker/actions/runs/4707215086/jobs/8348951927?pr=767#step:4:970
[4] https://github.com/datafaker-net/datafaker/actions/runs/4700592603/jobs/8335491891#step:4:969