Closed asolntsev closed 1 week ago
This Pull Request includes changes in multiple files which correspond to the optimization and improvement of our systems. Here are the crux points of this update:
Optimizing BaseFaker.java
:
The static variables have been removed for more efficient instance variable management. Certain methods were removed while some were updated, simplifying our processes and making use of newly implemented techniques in the ObjectMethods
class.
Introduction of ObjectMethods.java
:
A whole new class called ObjectMethods.java
was created. It includes functions aimed at identifying, retrieving, and executing methods based on their name or return type, enhancing our method management capabilities.
Updating ProviderRegistration.java
:
This file saw some modifications to its default implementations, making use of our newly developed ObjectMethods
class.
Improving Exception Handling in FakeValuesService.java
:
The process of resolution has been updated to furnish us with more detailed exception messages, aiding in quicker troubleshooting and problem-solving. This is made possible with the introduction of the new getProvider
method.
Refactoring Tests in FakerTest.java
and CustomFakerTest.java
:
The test cases in both FakerTest.java
and CustomFakerTest.java
were refactored to accommodate the new changes and practices introduced in this PR.
Adding tests in ObjectMethodsTest.java
:
New tests were introduced for the methods in the newly created class, ObjectMethods.java
, ensuring everything is functioning as it should.
Refining FakeValuesServiceTest.java
:
Testing in this class has been restructured for better matching and adherence to the new system in place with BaseFaker.getProvider
method and variables renaming for better clarity.
These changes will ensure more transparent, efficient, and maintainable code handling, thereby providing an improved experience for our development team and more stable release for our users.
Thanks for working on this
I guess we also need to run some measurement tests to see what this change brings to us I will run it today and post the result later
we also need to run some measurement tests
At least I run Issue1178Test
, and it takes ~the same time in main
branch and fix/memory-leak
.
there is no significant changes
probably on only one improvement for DatafakerSimpleMethods.numberBetween
about 10%, others are more or less same
before
Benchmark Mode Cnt Score Error Units
DatafakerSimpleMethods.firstname thrpt 10 9383.836 ± 110.342 ops/ms
DatafakerSimpleMethods.fullname thrpt 10 3108.838 ± 27.933 ops/ms
DatafakerSimpleMethods.numberBetween thrpt 10 116170.962 ± 705.899 ops/ms
DatafakerSimpleMethods.streetAddress thrpt 10 2213.100 ± 13.656 ops/ms
Benchmark Mode Cnt Score Error Units
DatafakerExpressions.bothify thrpt 10 13654.868 ± 78.549 ops/ms
DatafakerExpressions.letterify thrpt 10 18601.883 ± 1715.311 ops/ms
DatafakerExpressions.numerify thrpt 10 16980.816 ± 972.231 ops/ms
DatafakerExpressions.regexify thrpt 10 19546.992 ± 2126.820 ops/ms
Benchmark Mode Cnt Score Error Units
DatafakerCsvjson.csvJson thrpt 10 460.369 ± 44.570 ops/ms
after
===============================================================
Benchmark Mode Cnt Score Error Units
DatafakerSimpleMethods.firstname thrpt 10 9612.673 ± 171.756 ops/ms
DatafakerSimpleMethods.fullname thrpt 10 3137.267 ± 69.310 ops/ms
DatafakerSimpleMethods.numberBetween thrpt 10 132792.389 ± 277.564 ops/ms
DatafakerSimpleMethods.streetAddress thrpt 10 2258.682 ± 31.129 ops/ms
Benchmark Mode Cnt Score Error Units
DatafakerExpressions.bothify thrpt 10 13748.220 ± 1365.136 ops/ms
DatafakerExpressions.letterify thrpt 10 20836.751 ± 490.235 ops/ms
DatafakerExpressions.numerify thrpt 10 19378.905 ± 2497.980 ops/ms
DatafakerExpressions.regexify thrpt 10 21656.561 ± 271.221 ops/ms
Benchmark Mode Cnt Score Error Units
DatafakerCsvjson.csvJson thrpt 10 479.511 ± 12.053 ops/ms
Thank you!
Probably it's easier to review this PR commit-by-commit.
This PR removes three static fields that were growing endlessly:
BaseFaker.PROVIDERS_MAP
BaseFaker.CLASSES
FakeValuesService.REGEXP2SUPPLIER_MAP